0

I would like to query and sort posts by meta key "popularity" and these posts must have also another meta key "gone" with value "1" to query

$args = array(
        'post_status' => 'publish',
        'posts_per_page' => '150',
        'cat' => $cat_id, 
        'order' => 'DESC'
'meta_query'      => array(
    'relation'    => 'AND',
    'popularity' => array(
        'key'     => 'popularity',
        'orderby' => 'meta_value_num',
    ),
    'be_price'    => array(
        'key'     => 'gone',
        'value'    => '1'
    )
)                     
); 

2 Answers 2

-1

I am not sure what 'be_price' is for, but I think your $args should look like this:

$args = array(
    'post_status' => 'publish',
    'posts_per_page' => '150',
    'cat' => $cat_id, 
    'meta_key' => 'popularity',        
    'order' => 'DESC',
    'orderby' => 'meta_value_num',
    'meta_query' => array(
        'key'     => 'gone',
        'value'    => '1'
    )                     
);
-1
$args = array(
'post_status' => 'publish',
'posts_per_page' => '150',
'cat' => $cat_id,
'order' => 'DESC',
'meta_query'      => array(
'relation'    => 'AND',
'popularity' => array(
    'key'     => 'popularity',
    'orderby' => 'meta_value_num'
),
'gone' => array(
    'key'     => 'gone',
    'value'    => '1'
)
));

try this

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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