Independent ASC/DESC in multiple ORDER BY statement.
|Reported by:||ericmann||Owned by:||ericmann|
|Component:||Query||Keywords:||has-patch needs-testing needs-unit-tests|
WP_Query supports ordering results by multiple columns, but does not currently support independent ASC/DESC declarations on those columns. Instead, it concatenates the ORDER and ORDER BY statements together.
In some cases, it would be beneficial to independently set the order for these columns. An example offered on WP-Hackers:
I have a situation where I want to order a list of post both by author and date using WP_Query which isn't a problem since 'orderby' lets me do that. But I want the author part sorted ascending and date part sorted descending.
A normal MySql statement would end with ORDER BY author ASC, date DESC.
We should extend WP_Query to allow users to set their ordering parameters independently. This should be done in such a way as to not break backwards compatibility.
Change History (59)
comment:19 rosariobocca — 2 years ago
- Cc rosariobocca added
- Type changed from enhancement to feature request
comment:21 in reply to: ↑ 20 rosariobocca — 2 years ago
comment:28 nacin — 20 months ago
- Keywords needs-unit-tests added
- Type changed from feature request to enhancement