Order Custom post type loop by custom field (datepicker)

Your second approach should in my mind actually work, you do it like this:

Code:

$args = array(
    'post_type' => 'agenda',
    'posts_per_page' => -1,
    'meta_key' => 'datum_agenda',
    'orderby' => 'meta_value_num',
    'order' => 'ASC'
);
$my_query = new WP_Query( $args );

There are two pages at the ACF documentation you might want to read: Date Picker and Order posts by custom fields. Besides that the only thing that comes to mind would be how is the date formated and might the problem originate there, having yymmdd as value for the ACF »Date Picker« field »Save format« is recommended.

Leave a Comment