Opened 5 weeks ago
Last modified 5 weeks ago
#63130 new enhancement
Add comment_count Support to REST API for Enhanced Sorting and Gutenberg Integration
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | blocker | Version: | trunk |
Component: | REST API | Keywords: | has-patch |
Focuses: | rest-api | Cc: |
Description
Currently, the REST API does not support sorting posts by comment_count, which limits the ability to retrieve posts ordered by the number of comments. Adding comment_count support to the REST API will achieve two key objectives:
Enable Sorting by Comment Count in the REST API
Adding this feature will allow developers to sort posts by the number of comments directly in the REST API, enhancing the flexibility of post queries.
Integrate Comment Count Sorting into Gutenberg’s Latest Posts Block
Once the REST API is updated, this functionality can be leveraged to enhance the Latest Posts block in Gutenberg. The ability to sort posts by comment count was discussed in Gutenberg Issue #20046, and this feature was identified as missing in Revision 2 of the block.
This enhancement will provide users with a more dynamic way to display popular or highly engaged content while maintaining consistency between REST API capabilities and Gutenberg features.
Change History (2)
This ticket was mentioned in PR #8551 on WordPress/wordpress-develop by @vipulpatil.
5 weeks ago
#1
- Keywords has-patch added; needs-patch removed
#2
@
5 weeks ago
@swissspidy Can you look at this ticket and the PR.
Also the Gutenberg issue mentioned in the ticket is https://github.com/WordPress/gutenberg/issues/20046
also mentioned here,
https://github.com/WordPress/gutenberg/issues/22002
## Summary
This PR adds support for ordering posts by
comment_count
in the REST API by extending theorderby
parameter in theget_collection_params
method of theWP_REST_Posts_Controller
class.### Changes Made
comment_count
to the list of allowedorderby
parameters inget_collection_params
.### Why This is Needed: