0
$query_args = array(
'post_type' => 'post',
'posts_per_page' => 6,
'order'=> 'desc',
'orderby' => 'meta_value date',
'paged' => $paged
 ); 

This is my current query to sort posts. What it does that it shows posts with any post meta first and then sorts the remaining ones by date. However in the wordpress reference it says that meta_key should be present for it to work.

What's actually going on here?

0

You must add meta_key to your array. How else the query will know what meta value to use?

Try adding 'meta_key' => 'your_key'

  • but without putting meta_key it shows the posts with custom fields first and then shows the remaining ones.. my question is why does that happen – Megh Gandhi Jan 22 '17 at 11:37
  • What do you want to happen? it is normal - it is ordering posts with some "meta_value" first, and then the ones without it at. normal SELECT query action. – kirillrocks Jan 22 '17 at 16:34
  • so what is that meta value? @kirillrocks – Megh Gandhi Jan 22 '17 at 17:19

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.