[wp-trac] [WordPress Trac] #24133: WP_Query, multiple 'orderby' values glitch
WordPress Trac
noreply at wordpress.org
Thu Mar 6 21:17:50 UTC 2014
#24133: WP_Query, multiple 'orderby' values glitch
--------------------------+------------------------
Reporter: racura | Owner:
Type: defect (bug) | Status: closed
Priority: normal | Milestone:
Component: Query | Version: 3.5.1
Severity: normal | Resolution: duplicate
Keywords: | Focuses:
--------------------------+------------------------
Description changed by SergeyBiryukov:
Old description:
> According to the documentation, WP_Query argument 'orderby' allows for
> multiple values, but it doesn't work.
>
> Looking in the code i found out why, the 'order' is only being applied to
> the last item in the list.
>
> So for instance:
> ('orderby' => 'title menu_order', 'order' => 'DECS')
> Will end up as
> "ORDER BY $wpdb->posts.menu_order, $wpdb->posts.post_menu_order DECS"
>
> To fix (I hope), the following needs to be done to query.php line 2387
> $orderby_array[] = $orderby.' '.$q['order'];
New description:
According to the documentation, WP_Query argument 'orderby' allows for
multiple values, but it doesn't work.
Looking in the code i found out why, the 'order' is only being applied to
the last item in the list.
So for instance:
{{{
('orderby' => 'title menu_order', 'order' => 'DESC')
}}}
Will end up as
{{{
"ORDER BY $wpdb->posts.menu_order, $wpdb->posts.post_menu_order DESC"
}}}
To fix (I hope), the following needs to be done to query.php line 2387
{{{
$orderby_array[] = $orderby.' '.$q['order'];
}}}
--
--
Ticket URL: <https://core.trac.wordpress.org/ticket/24133#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list