WP Event Manager WP_Query not excluding past events in loop
-
I am trying to call only future events in a loop but strange things are happening. Different things happen with different categories and this loop works correctly with some categories and not others. I have two categories, ‘workshops’ and ‘third-party-events’ Here is my code, any help will be much appreciated.
<?php $loop = new WP_Query(array( 'post_type' => 'event', 'event-categories'=> 'workshops', 'orderby' => 'meta_value', // We want to organize the events by date 'meta_key' => '_event_start_date', // Grab the "start date" field created via "More Fields" plugin (stored in YYYY-MM-DD format) 'posts_per_page' => 20, 'order' => 'ASC', 'meta_query' => array( // WordPress has all the results, now, return only the events after today's date array( 'key' => '_event_start_date', // Check the start date field 'value' => date("d-m-Y"), // Set today's date (note the similar format) 'compare' => '>=', // Return the ones greater than or equal to today's date 'type' => 'DATE' // Let WordPress know we're working with date ) ) )); ?> <div class="container event-col-container"> <?php while ( $loop->have_posts() ) : $loop->the_post(); ?> <?php if ( has_post_thumbnail() ) { ?> <!-- Start Columns --> <div class="event-in-cols"> <div class="event-col"> <p><?php the_date(); ?></p> <div class="event-col-img"> <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( 'full' ); ?></a> </div> <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> </div> </div><!-- /Columns --> <?php } ?> <?php endwhile; wp_reset_postdata(); ?> </div>
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘WP Event Manager WP_Query not excluding past events in loop’ is closed to new replies.