Using the Custom Post Type UI extension, I've created a 'Event' custom post-type, which fields are populated using custom fields (created with the extension Advanced Custom Fields) such as 'date-debut' and 'date-fin'.
On an archive page dedicated to this post-type, I'm trying to display the 10 next (current or future) events, ordered chronologically by beginning date.
The sorting part seems to be OK by itself; but it doesn't work anymore when I add the tests on dates, and anyway those don't work either.
Here is my code:
$current_date = date('ymd'); $my_query = new WP_Query( array ( 'post_type' => 'mna_event', 'posts_per_page' => 10, 'orderby' => 'meta_value_num', 'meta_key' => 'date_debut', 'order' => 'ASC', 'meta_query' => array ( 'relation' => 'OR', array ( 'key' => 'date_debut', 'value' => $current_date, 'compare' => '>=' ), array ( 'key' => 'date_fin', 'value' => $current_date, 'compare' => '>=' ) ) ) );
Advice on the matter would be very much appreciated. Thanks