0

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',  
      ),
    ),
    );

1 Answer 1

0

The meta_query has to be an array of array to manage the relation between the meta queried.

You can read more on the codex page about wp_query here

In an other side, post_type, post_status, has nothing to do on your meta_query clause, they are already in the main arguments if the query.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.