[wp-trac] [WordPress Trac] #28012: orderby post__in interferes with menu_order

WordPress Trac noreply at wordpress.org
Sat May 3 07:18:07 UTC 2014


#28012: orderby post__in interferes with menu_order
------------------------------------------+------------------
 Reporter:  Matthias82                    |       Owner:
     Type:  defect (bug)                  |      Status:  new
 Priority:  normal                        |   Milestone:  4.0
Component:  Query                         |     Version:  3.9
 Severity:  normal                        |  Resolution:
 Keywords:  needs-patch needs-unit-tests  |     Focuses:
------------------------------------------+------------------

Comment (by haxxxton):

 I am having a similar problem since upgrading to 3.9, but even just with
 top level posts (ie. not nested).
 Here is my code:


 {{{
     $icons = array(310, 230, 272, 247, 234);

     echo '<pre>';
     print_r($icons);
     echo '</pre>';

     $attached_images = new WP_Query(array(
         'post__in' => $icons,
         'post_type' => 'attachment',
         'post_parent' => $post->ID,
         'post_mime_type' => 'image',
         'post_status' => 'inherit',
         'posts_per_page' => '-1',
         'orderby' => 'post__in'
     ));

     echo '<ul>';
     foreach($attached_images->posts as $icon){
         echo '<li>'.$icon->ID.' - '.$icons->menu_order.'</li>';
     }
     echo '</ul>';
 }}}

 expected output:

 {{{
 Array
 (
     [0] => 310
     [1] => 230
     [2] => 272
     [3] => 247
     [4] => 234
 )
 310 - 79
 230 - 100
 272 - 42
 247 - 17
 234 - 4
 }}}


 generated output:

 {{{
 Array
 (
     [0] => 310
     [1] => 230
     [2] => 272
     [3] => 247
     [4] => 234
 )
 234 - 4
 247 - 17
 272 - 42
 310 - 79
 230 - 100
 }}}

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


More information about the wp-trac mailing list