I my project I have the events page where it display all the upcoming events according to the dates. But my client needs to have one more category called "Past events", where all the past events should be stored there. So that when the event expires it has to go that particular past event category. Can anyone suggest me how to achieve this?
Help needed.
I my project I have the events page where it display all the upcoming events according to the dates. But my client needs to have one more category called "Past events", where all the past events should be stored there. So that when the event expires it has to go that particular past event category. Can anyone suggest me how to achieve this?
Help needed.
you would need to use the date
query:
$args = array (
'cat' => '1234', // if category being used
'post_type' => 'events', // if custom post type
'paged' => get_query_var('paged'),
'order' => 'DESC',
'paged' => $paged,
'date_query' => array( // this is the thing you need
array(
'before' => array( // this is 'before today'...
'year' => date('Y'),
'month' => date('m'),
'day' => date('d')
),
'inclusive' => true,
),
),
);
$past_events = new WP_Query($args);
category, post type, and date in which you deem to be 'past' can be manipulated there.