Make WordPress Core

Opened 8 years ago

Closed 3 years ago

#36701 closed enhancement (duplicate)

Pages parameter for get_comments

Reported by: mireillesan's profile mireillesan 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)

#1 @boonebgorges
8 years ago

  • Keywords needs-patch needs-unit-tests added
  • Milestone changed from Awaiting Review to Future Release

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_Query calls it posts_per_page, while WP_User_Query calls it number. Since we already have number in WP_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 pass offset=21&paged=5&number=20.

#2 @birgire
7 years ago

  • Keywords close added

Seems to be resolved in #38268

#3 @hellofromTonya
3 years ago

  • Keywords needs-patch needs-unit-tests removed
  • Milestone Future Release deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Marking this ticket as duplicate of #38268.

Please note, the enhancement requested in this ticket, i.e. the paged argument, was added to WP_Comment_Query in changeset [41287].

Note: See TracTickets for help on using tickets.