0
votes

I have the values meta_key and meta_value like 0,1, then I will use the query_posts for getting that data in descending order use the following query.

$arguments = array(
'post_type' => 'ad',
'post_status'=>'publish',
'meta_query' => array(array('key'=>'et_featured',
'value'=>array('0','1'),
'orderby'=>'meta_value',
'order'=>'DESC',
),
)
);
query_posts($arguments);

But it only shows the post_type='ad' in descending order. If I use an another query like :

$arguments = array(
'post_type' => 'ad',
'post_status'=>'publish',
'meta_query' => array(array('key'=>'et_featured',
'value'=>array('1'),
'orderby'=>'meta_value',
'order'=>'DESC',
),
)
);

It only shows the featured results. I need full of ad posts with order by descending based on et_featured values 0 and 1.

i used also a different query like

query_posts('post_type=ad&post_status=publish&meta_key=et_featured&meta_value=1&meta_value=0&orderby=meta_value&order=DESC');

1

1 Answers

0
votes
$arguments = array(
    'post_type' => 'ad',
    'post_status'=>'publish',
    'meta_key'=>'et_featured',
    'meta_query' => array(
        array(
            'key'=>'et_featured',
            'value'=>array('0','1'),
        )
    ),
    'orderby'=>'meta_value',
    'order'=>'DESC',
);

try it