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!
<?php
$query = new WP_Query( array( 'post_type' => 'tribe_events',
'meta_query' => array(
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>';
endwhile;
}
wp_reset_query();
?>
I've also tried changing the meta value to
'value' => date('Y-m-d', strtotime('-1 week')),
but this didnt work either...
Thanks