I’ve mostly encountered this use case when making an “event” custom post type: the client wants to see only events ‘in the future.’
This assumes that our date is in the future (where date_time is the ACF field):
$today = date('Y-m-d H:i:s'); $args = array( 'post_type' => 'event', 'posts_per_page' => 10, 'paged' => $paged, 'order' => 'DESC', 'orderby' => 'date_time', 'meta_key' => 'date_time', 'meta_query' => array( array( 'key' => 'date_time', 'compare' => '<=', 'value' => $today, ) ) ); |