• Nathan Hawkes

    (@natehawkes)


    I have a custom post type for events and an archive page. I am looking to display only upcoming events on the archive page. However, the archive is displaying posts from March 2015, and considering that I am posting this on April 2015, you can imagine that isn’t what I’m looking for.

    Here is my code at the moment:

    $event_args = array(
              'post_type' => 'event',
              'posts_per_page' => -1,
              'ignore_sticky_posts' => 1,
              'order' => 'ASC',
              'orderby' => 'meta_value_num',
              'meta_key' => 'wca_events_startdate',
              'meta_query' => array(
                'key' => 'wca_events_enddate',
                'compare' => '>',
                'value' => date( 'd/m/Y' ),
                'type' => 'NUMERIC'
              )
            );

    As you can tell, there are two custom fields – wca_events_startdate and wca_events_enddate. I want the order of the dates to be from the next event to the furthest away based on wca_events_startdate. I also want to forget any events that have passed – where the wca_events_enddate is after today. The dates in both fields are in a d/m/Y format.

    Does anyone see where I’ve gone wrong?

  • The topic ‘CPT Archive Query showing posts it shouldn't’ is closed to new replies.