within one of my query_posts
I use 'meta_key' => 'clpr_topcoupon', ;meta_value'=> 1,
now I would like to show post without as well but the one with meta_value
first.
I tried:
'meta_query' => array(
'relation' => 'OR',
array( //check to see if date has been filled out
'meta_key' => 'clpr_topcoupon',
'meta_value'=> 1,
),
array( //if no date has been added show these posts too
'meta_key' => 'clpr_topcoupon',
'meta_value'=> 0,
)
),
However it is not working. It shows the one with 0
first.
within one of my query_posts
I use 'meta_key' => 'clpr_topcoupon', ;meta_value'=> 1,
now I would like to show post without as well but the one with meta_value
first.
I tried:
'meta_query' => array(
'relation' => 'OR',
array( //check to see if date has been filled out
'meta_key' => 'clpr_topcoupon',
'meta_value'=> 1,
),
array( //if no date has been added show these posts too
'meta_key' => 'clpr_topcoupon',
'meta_value'=> 0,
)
),
However it is not working. It shows the one with 0
first.
'meta_key' => 'clpr_topcoupon',
'orderby' => 'meta_value_num',
'order' => 'DESC'
You can solve the problem by using order by clause then there will no need to write meta query. Please use the above code to solve your problem.It will show the posts according to descending order of the value in meta key.