I have a WordPress site that has a custom post type of Event which includes an Advanced Custom Field (ACF) Repeater field with a date field included. I am looking to order the Event Post Type on the archive view by the earliest Date Field within the ACF Repeater.
I had tried using a nested meta_query by adding the key of dates_%_date
but the returned Events don't seem to be in the proper order. The repeater field is named dates
and the sub_field for it is named date
.
Does the order of the repeater fields matter? IE: does it make a difference which entry in the repeater field has the date? I'm looking to compare ALL dates from the repeater field.
$args['meta_query'] = array(
array(
'key' => 'dates_%_date',
'compare' => '>=',
'value' => $today
)
);
$args['meta_key'] = 'dates_%_date';
$args['order'] = 'ASC';
$args['orderby'] = 'meta_value';
Is there anything glaringly wrong in this query? Or another way to run this?