WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 2 months ago

Last modified 2 months ago

#21571 closed enhancement (duplicate)

Add support multiple comment types in get_comments

Reported by: borkweb Owned by: boonebgorges
Milestone: Priority: normal
Severity: normal Version: 3.8.1
Component: Comments Keywords: has-patch
Focuses: Cc:

Description

Custom comment types are a nice way to categorize comments, however, if you wish to retrieve multiple comment types you cannot use get_comments. This enhancement request (patch attached) adds support for multiple comment types a la:

$comments = get_comments( array(
  'post_id' => $post->ID,
  'type' => array(
    'a-sweet-comment-type',
    'some-other-comment-type',
  ),
));

Attachments (1)

comment.diff (588 bytes) - added by borkweb 3 years ago.
Patch for adding multiple comment_type support

Download all attachments as: .zip

Change History (10)

@borkweb3 years ago

Patch for adding multiple comment_type support

comment:2 @vhauri3 years ago

+1 I have a couple of use cases this would be very helpful for, e.g. displaying a custom comment type in a loop with regular comments, without doing multiple comment queries and then merging the resulting data. This is particularly important because I have more comment types than I want to display, so displaying all the types would not work.

Last edited 3 years ago by vhauri (previous) (diff)

comment:3 @borkweb12 months ago

  • Keywords has-patch added
  • Version set to 3.8.1

comment:4 @SergeyBiryukov12 months ago

  • Keywords 4.0-early added
  • Milestone changed from Awaiting Review to Future Release

comment:6 @ragulka5 months ago

I'd like to weigh and add my vote for this enhancement. I'm currently working on a plugin that uses custom comment types and this would definitely make querying multiple types in a single request a lot easier.

Also, I think it makes a lot of sense, because then it would reflect the logic in WP_Query which allows querying posts using an array of post types.

comment:7 @boonebgorges4 months ago

  • Keywords 4.0-early removed

Related: #12668.

comment:8 @boonebgorges4 months ago

  • Owner set to boonebgorges
  • Status changed from new to reviewing

comment:9 @boonebgorges2 months ago

  • Milestone Future Release deleted
  • Resolution set to duplicate
  • Status changed from reviewing to closed

Duplicate of #12668.

borkweb, thanks for the patch. As of [30096], the 'type' parameter accepts an array of types. We also now have a 'type__in' param.

Last edited 2 months ago by boonebgorges (previous) (diff)
Note: See TracTickets for help on using tickets.