[wp-trac] [WordPress Trac] #17065: Independent ASC/DESC in multiple ORDER BY statement.

WordPress Trac noreply at wordpress.org
Thu Mar 6 10:00:10 UTC 2014


#17065: Independent ASC/DESC in multiple ORDER BY statement.
-------------------------------------------------+-------------------------
 Reporter:  ericmann                             |       Owner:  ericmann
     Type:  enhancement                          |      Status:  new
 Priority:  normal                               |   Milestone:  Future
Component:  Query                                |  Release
 Severity:  normal                               |     Version:  3.1
 Keywords:  has-patch needs-testing needs-unit-  |  Resolution:
  tests                                          |     Focuses:
-------------------------------------------------+-------------------------

Comment (by qsz):

 Hello,

 I want to order data by double parameters such as meta_value_num and
 title.

 Code

 {{{
 $args = array(
                 'posts_per_page' => 500,
                 'orderby' => 'meta_value_num title',
                 'meta_key' => '_ss_views',
                 'order' => 'DESC',
                 'ignore_sticky_posts' => 1
         );
 }}}

 In this case all post are ordered by title (DESC) then by meta_value_num
 (ASC)

 What I want is vice versa - First to order meta_value_num from the highest
 to lowest (DESC) and then order by title in alphabetical order (ASC).

 Can you suggest some solutions?

--
Ticket URL: <https://core.trac.wordpress.org/ticket/17065#comment:56>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list