The following code pulls events from a custom post type that used Advanced Custom Fields, that is shown on an event listing page. It shows upcoming events as desired except when the event is on the current day. So if an event's start day was today it doesn't show.
For compare it had '>' and changed to '>=" which would presumably also then show dates that are on the current date but adding the = doesn't make a difference and I do just, "=" then nothing shows. Have tried changing OR to AND and didn't seem to make a difference either. The only thing that works is if I change the event date to be any date in the future (aka not today).
<?php
// Upcoming Events & Events Underday
$now = date('Y-m-d H:i:s');
$args = array(
'post_type' => 'events_post_type',
'posts_per_page' => -1,
'meta_query' => array(
'relation' => 'OR',
'date_upcoming_clause' => array(
'key' => 'event_start_date',
'compare' => '>=',
'value' => $now,
'type' => 'DATETIME'
),
),
'orderby' => array(
'date_upcoming_clause' => 'ASC',
),
);
$the_query = new WP_Query($args);
?>
Update: Commenter noted to remove H:i:s and while that works then it would still show event as upcoming after it passes while it's the same day as event. But that helped me realized in the code I'm not doing a compare for the time. So I've added that but doesn't work at all (doesn't show any events). But getting closer! Updated code below:
<?php
// Upcoming Events & Events Underday
$now = date('Y-m-d');
$now2 = date('H:i:s');
$args = array(
'post_type' => 'events_post_type',
'posts_per_page' => -1,
'meta_query' => array(
'relation' => 'OR',
'date_upcoming_clause' => array(
'key' => 'event_start_date',
'compare' => '>=',
'value' => $now,
'type' => 'DATETIME'
),
),
'time_upcoming_clause' => array(
'key' => 'event_end_time',
'compare' => '<=',
'value' => $now2,
'type' => 'DATETIME'
),
'orderby' => array(
'date_upcoming_clause' => 'ASC',
),
);
$the_query = new WP_Query($args);
?>
event_end_time in acf holds just the time and event start date holds just the date. Have tried all different things such as reversing the > < among other things but no luck. In ACF have it set to return m/d/y for date and g:ia for time. I've tried using those for $now and $now2 but doesn't seem to help.