I need to show the result of 3 queries and I made this query but I can not show the result, I throw a table that does not have the order I want. This is the query:

$args3 = array(
‘post_type’ => $directory_url_2, // enter your custom post type
‘paged’ => $paged,
‘post_status’ => ‘publish’,
‘meta_query’ => array(
‘post_type’ => $directory_url_2, // enter your custom post type
‘paged’ => $paged,
‘post_status’ => ‘publish’,
‘relation’ => ‘AND’,
‘premium_clause’ => array(
‘meta_key’ => ‘premium’,
‘meta_compare’ => ‘LIKE’,
‘orderby’ => array(‘_post_views’ => ‘DESC’ , ‘post_name’ => ‘ASC’)
),
‘other_clause’ => array(
‘meta_key’ => ‘premium’,
‘meta_compare’ => ‘NOT EXISTS’,
‘orderby’ => array(‘_post_views’ => ‘DESC’ , ‘post_name’ => ‘ASC’)
),
‘orderby’ => array(
‘premium_clause’ => ‘ASC’,
‘other_clause’ => ‘ASC’,
),
),
);

Read more here: Query 3 meta_key and orderby


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: