Make WordPress Core

Opened 4 weeks ago

Last modified 4 weeks ago

#61632 new enhancement

Allow ordering of posts by `status`

Reported by: ntsekouras's profile ntsekouras Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Query Keywords:
Focuses: Cc:

Description

Currently it's not possible to order posts by status in the REST API: https://github.com/WordPress/wordpress-develop/blob/trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php#L2899.

This is useful though with the new views (Data Views and pages list) in site editor and the advancing of redesigning of WP admin, which will utilize way more the REST API.

Change History (2)

#1 @swissspidy
4 weeks ago

  • Component changed from REST API to Query

WP_Query itself by default does not support ordering by post status, hence changing the component.

https://github.com/WordPress/wordpress-develop/blob/349590c8135b003857b47ff1a4636dc283d8b71c/src/wp-includes/class-wp-query.php#L1662-L1685

I don't see why anyone would want to order by post status though, as most posts have the same status anyway. _Filtering_ by post status makes much more sense.

I don't know why the new data views would change this.

#2 @jameskoster
4 weeks ago

Good points, I agree it is questionable why a user might want to sort by status and that filtering is generally more useful.

However it would be good to be consistent around this. Currently in data views it is possible to sort by author, which is an equally questionable feature.

So my question is; should it be possible to sort by any text based field, or should we be selective about it? The former feels more flexible, even if it is only serving very niche use cases.

Note: See TracTickets for help on using tickets.