Opened 10 years ago
Closed 5 years ago
#36701 closed enhancement (duplicate)
Pages parameter for get_comments
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | 4.5.1 |
| Component: | Comments | Keywords: | close |
| Focuses: | Cc: |
Description
Would it also be possible to add a $paged parameter to get_comments?
That way we can have more control over the pagination.
For example:
Reviews are usually just comments with an extra meta_key.
To display only the reviews, we can easily filter them inside get_comments.
There's one issue, the pagination (paginate_comments_links) grabs total comment count and ignoring the fact that get_comments only displays selected comments based on meta_key.
Hope it makes sense what I wrote, if not, just let me know.
Change History (3)
Note: See
TracTickets for help on using
tickets.
Hi @mireillesan - Thanks for the ticket, and welcome to WordPress Trac!
Pagination parameters seem like a good idea. The parameter name for the page number, based on what we use in other query classes, would be
paged. We are less consistent about the "per page" parameter name -WP_Querycalls itposts_per_page, whileWP_User_Querycalls itnumber. Since we already havenumberinWP_Comment_Query, it makes sense to use it here too.When introducing new parameters like this, which are conceptually similar to other existing params (in this case,
offset), we should have unit tests that demonstrate which one takes precedence - ie, what happens when you passoffset=21&paged=5&number=20.