Automattic / Automattic/jetpack
WordPress.com REST API: allow custom order_by parameters in sites/%24site/posts/ queries
- Dominant language
- PHP
- Stars
- 1.8k
- Forks
- 898
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 774
Description
#### Is your feature request related to a problem? Please describe.
I am building an app that loads data from my self hosted Wordpress website. I also integrated with the forum provided by bbPress. The app orders topics displayed in a forum according to bbPress `_bbp_last_active_time` meta, but I can't replicate that behaviour on the API side. I could do it using WP-JSON v2 API but all my app uses the Jetpack API so if I could keep it for all requests it would be easier than managing multiple deserializers.
While I understand bbPress is not edited by you, it seems you do support it a bit, cf https://developer.wordpress.com/2013/04/26/custom-post-type-and-metadata-support-in-the-rest-api/
#### Describe the solution you'd like
The "easiest" way seems to add the ability to `order_by` a given meta. This would possibly allow a whole lot of uses as a side effect, and you wouldn't have to think about bbPress inner implementation.
#### Describe alternatives you've considered
Another way could be to create a specific route that makes use of bbPress API like https://www.buddyboss.com/resources/reference/functions/bbp_forum_query_topic_ids/. But it would mean depending on the plugin which doesn't seem ideal
I've also thought of contacting bbPress authors to sync `modified` date to `_bbp_last_active_time` but this is not what that parameter is for
Third option was to extend the jetpack API myself but I'm pretty sure this requires way more understanding than I have and the plugin doesn't have the filters or actions needed to do so.
#### Additional context
It seems WP_Query is already able to do this https://developer.wordpress.org/reference/classes/wp_query/#order-orderby-parameters
Contributor guide
Research direction
Start at the Jetpack API sites/%24site/posts/ route and trace how its order_by parameter reaches WP_Query. Compare the requested meta-based ordering with the WP_Query order/orderby parameters described in the issue, then identify the relevant API tests and verify that custom ordering works without breaking existing queries.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, wordpress
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100