WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#29666 closed defect (bug) (invalid)

Mulitiple orderby/order pairs

Reported by: lavrenuk Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.0
Component: Query Keywords:
Focuses: Cc:

Description

In documentation: http://codex.wordpress.org/Class_Reference/WP_Query
Chapter: Mulitiple orderby/order pairs

this code does not work,
sorts only on one field

$the_query = new WP_Query (
    array (
       'posts_per_page' => -1,
       'cat'            => $ccat->cat_ID,  
       'orderby'        => array (
         'meta_value_num' => 'DESC',
         'title'          => 'ASC',
       ),
       'meta_key'       => 'count',
   )
);

Change History (3)

#1 @jesin
6 years ago

  • Keywords reporter-feedback added

I tried out the code on the following data and it worked fine for me:

post_title postmeta - count
Edge Case: Nested And Mixed Lists 10
Hello world! 01
Markup: Image Alignment 10
Media: Twitter Embeds 05
Post Format: Video (VideoPress) 10
Template: Featured Image (Vertical) 01

This is the result I got:

post_title postmeta - count
Edge Case: Nested And Mixed Lists 10
Markup: Image Alignment 10
Post Format: Video (VideoPress) Markup: Image Alignment 10
Media: Twitter Embeds 05
Hello world! 01
Template: Featured Image (Vertical) 01

Maybe your count field has unique values?

#2 @lavrenuk
6 years ago

  • Keywords close added; reporter-feedback removed
  • Resolution set to invalid
  • Status changed from new to closed

Sorry, I probably made a mistake.
I wanted to get this result.

post_title postmeta - count
Edge Case: Nested And Mixed Lists 10
Markup: Image Alignment 1
Media: Twitter Embeds 14
Hello world! 0
Post Format: Video (VideoPress) 0
Template: Featured Image (Vertical) 0

#3 @DrewAPicture
6 years ago

  • Keywords close removed
  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.