0

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.

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.