[wp-trac] [WordPress Trac] #38034: post__in orderby not working when passed in an array to orderby

WordPress Trac noreply at wordpress.org
Tue Nov 22 10:14:41 UTC 2016


#38034: post__in orderby not working when passed in an array to orderby
-------------------------------+------------------------------
 Reporter:  kelvink            |       Owner:
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Query              |     Version:  4.6
 Severity:  normal             |  Resolution:
 Keywords:  reporter-feedback  |     Focuses:
-------------------------------+------------------------------

Comment (by kelvink):

 Replying to [comment:3 helen]:
 > Hi @kelvink - thanks for your report. Could you also provide the query
 set up that does work for you?
 >
 > Not new to trunk, so moving back to 4.6, though it would be something
 that's existed longer than that I imagine.

 Works:
 {{{#!php
 <?php
 $query = new WP_Query( array(
     'post__in' => array( 19, 21, 27, 16 ),
     'orderby' => 'post__in'
 ));
 }}}

 Does NOT work:
 {{{#!php
 <?php
 $query = new WP_Query( array(
     'post__in' => array( 19, 21, 27, 16 ),
     'orderby' => array( 'post__in' )
 ));
 }}}

 My fix makes {{{post__in}}} orderby work if you pass it in an array. So
 you can use the {{{post__in}}} orderby in conjunction with other ordering
 parameters.

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


More information about the wp-trac mailing list