0

If the main query args look like this:

'orderby' => 'meta_value_num',
'meta_key' => 'price',
'order' => 'DESC'

What orderby does the query use if the meta_key value is the same for multiple results? So, in the above example, if multiple items have the same price, how does the query order those items? Like a sub-orderby... I thought it would be publish date, but it isn't.

  • 1
    If i'm not mistaken, you can use multiple orderby values. So you could say orderby => 'meta_value_num title' You can read more about that here: WP_Query Orderby – Howdy_McGee Jan 21 '14 at 22:27
  • Thanks for the response @Howdy_McGee. Unfortunately, that doesn't seem to work if you specify a meta_key. The examples in the Codex for the fallback orderby parameter use only orderby and order and skip the meta_value or meta_key arguments. What happens is that orderby defaults to ASC when you add a fallback to orderby if meta_key is present. – Charles Jan 22 '14 at 9:29

Your Answer

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

Browse other questions tagged or ask your own question.