I’ve been trying to order these exhibitions based on the end_date custom field created with Advanced Custom Fields. I’m not able to properly get this working. I need the most recent dates first. I need to also only get posts with the exhibition_status of ‘past’. For the life of me I can’t get this working and the below code is just the latest non working interation.
$args = array ( 'post_type' => 'exhibitions', 'meta_query' => array( 'relation' => 'OR', 'query_one' => array( 'key' => 'exhibition_status', 'value' => 'past', // Optional ), 'query_two' => array( 'key' => 'end_date', 'compare' => '>=', ), ), 'orderby' => 'end_date', 'order' => 'ASC', 'post_status' => 'publish', 'posts_per_page' => 10, 'paged' => get_query_var( 'paged' ),
Go to Source