Query clauses have a few issues that are not documented and you only find them by finding theme.
Query clauses do not work well with nested meta queries. Honestly, I don’t remember if they work at all with nested meta queries.
Query clauses 100% do not work with a nested query that has multiple meta keys associated with it.
// order by true/false field, desc and then date field asc $meta_query = array( 'relation' => 'AND', 'qw1' => array( // it does not matter what value this field is // it is only used for ordering 'key' => 'activi_datumperiode', 'compare' => 'EXISTS' ), 'qw2' => array( // note that ACF fields not stored as dates in DB // they are text values (or number) 'key' => 'activi_datum', 'value' => date('Ymd'), 'compare' => '>=' ), ); $orderby = array('qw1' => 'DESC', 'qw2' => '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!
© 2023 Advanced Custom Fields.