Modern Tribe Calendar wp-query with meta query not working at all

I’ve been searching for a good few days now trying to get my WordPress event calendar by modern tribe working as I need it to.

I have hundreds of order by and delivery dates in DB each one separated by about 5-10 weeks. what I’m trying to achieve is a list where I can see the all the events starting on today’s or yesterday’s date.

This sounds simple however the problem appears to be when you query events between two dates it will query both the start and end date giving you historical events which don’t need to be seen and can be confusing.

I believe the way to overcome this is with a wp_query and meta_query but no matter which way I try to add the meta query to sort by start date only it breaks the whole thing.

this is the query below any help would be awsome as I’ve little hair left to pull out!

  $query = new WP_Query( array( 'post_type' => 'tribe_events',
    'meta_query' => array(
            'key' => '_EventStartDate',
            'value' => date('Y-m-d H:i:s', strtotime('-1 week')),
            'compare' => 'date'
  ) );
  if ($query->have_posts())
    while ($query->have_posts()) : $query->the_post();
        echo $query->post->EventStartDate . ' ';
        echo $query->post->post_title . '</br>';


I’ve also tried changing the meta value to

  'value' => date('Y-m-d', strtotime('-1 week')),

but this didnt work either…


Solutions Collecting From Web of "Modern Tribe Calendar wp-query with meta query not working at all"

What I would do is create a query for the _EventStartDate with a custom ‘eventDisplay’. This will grab all events, ordered by the start date. Then, once you get into the loop; compare the start date to a specific date that you want to output. tribe_get_start_date() accepts a date format parameter (see here) that will allow you to return the format that you would like to compare against. Note, This code is untested but should put you on the right track.

$args = array(
    'post_type'=> 'tribe_events',
    'posts_per_page'=> 10,
    'meta_key'=> '_EventStartDate',
    'orderby'=> '_EventStartDate',
    'order'=> 'DESC',
    'eventDisplay'=> 'custom',

$query = new WP_Query($args);

if ($query->have_posts()) {
    while ($query->have_posts()) : $query->the_post();
        if(tribe_get_start_date() != [INSERT DATE TO COMPARE WITH]) {
            echo tribe_get_start_date() . ' ';
            the_title() . '</br>';