Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
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 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. –  chazbeaner Jan 22 at 9:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.