How to “orderby” the first array in a meta_query that uses multiply keys?
-
22-10-2019 - |
Question
My query is currently sorting by end date. How can I make it so it will sort by the start date?
$args = array ('post_type' => 'events',
'meta_query' => array(
array(
'key' => 'start_date',
'value' => $min_date,
'compare' => '>'
),
array(
'key' => 'start_date',
'value' => $max_date,
'compare' => '<'
),
array(
'key' => 'end_date',
'value' => $current_date,
'compare' => '>'
)
),
'orderby' => 'meta_value',
'order' => 'ASC'
);
Solution
try adding:
'meta_key' => 'start_date'
Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange