Independent ASC/DESC in multiple ORDER BY statement.
|Reported by:||ericmann||Owned by:||ericmann|
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 (85)
comment:19 @rosariobocca — 4 years ago
- Cc rosariobocca added
- Type changed from enhancement to feature request
comment:21 in reply to: ↑ 20 @rosariobocca — 4 years ago
comment:28 @nacin — 3 years ago
- Keywords needs-unit-tests added
- Type changed from feature request to enhancement
comment:29 follow-up: ↓ 30 @scribu — 3 years ago
comment:50 @jameslnewell — 22 months ago
comment:60 follow-up: ↓ 62 @wonderboymusic — 13 months ago
- Keywords needs-testing needs-unit-tests removed
comment:68 @nacin — 12 months ago
- Resolution set to fixed
- Status changed from new to closed
- Type changed from enhancement to task (blessed)