I have the following:
$args = array(
'post_type' => 'events',
'posts_per_page'=> 6,
'post_status'=> 'publish',
'meta_query' => array(
'relation' => 'OR',
'event_passport' => array(
'key' => 'event_product',
'value' => 'featured',
'compare' => '=',
),
'event_dates' => array(
'key' => 'event_dates',
'type' => 'DATETIME',
)
),
'orderby' => array(
'event_passport' => 'DESC',
'event_dates' => 'DESC',
),
);
Say for example I have 3 events where the event_product
is featured
.
What I want to do is display these 3 featured events first, then show the rest of the events.
At the moment this is not working and I’m not sure what I need to do to achieve this.
Any help is much appreciated, thank you!
2
Answers
You have to get both posts list separately and merge them into one array and use that loop for display post in frontend.
try modifying the query directly using posts_clauses filter.
The code below is untested, but the idea is to join individual table based on its meta key, then modify the order clause based on the value of that meta key.