In an interesting twist of fate, I’m doing this exact thing for my client as well – so I’ll update this and confirm if the above works, or if not, what I did instead.
Ignore my previous post, I found a more practical way of doing this here: https://support.advancedcustomfields.com/forums/topic/how-to-orderby-multiple-meta_key/
WP core have revamped the orderby function to accept array inputs, so after a bit of poking around, this is the method that I’ve used and confirmed:
$todays_date = current_time('Ymd'); $args = array( 'post_type' => 'events', 'posts_per_page' => '-1', 'meta_query' => array( 'relation' => 'AND', 'date_clause' => array( 'key' => 'event_date', 'compare' => '>=', 'value' => $todays_date, ), 'time_clause' => array( 'key' => 'event_time', 'compare' => 'EXISTS', ), ), 'orderby' => array( 'date_clause' => 'ASC', 'time_clause' => 'ASC', ) );
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!