WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 8 months ago

#20597 new enhancement

Allow WP_Comment_Query::query to filter by category — at Version 2

Reported by: sambauers Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 3.4
Component: Comments Keywords: needs-patch
Focuses: Cc:

Description (last modified by helenyhou)

The attached patch allows WP_Comment_Query::query to accept three additional arguments:

  • cat
  • category__in
  • category__not_in

The resulting comments are then filtered by these category arguments as well as any other arguments.

These arguments work the same way as their WP_Query counterparts.

I would appreciate advice on the appropriateness of using INNER JOIN (as I have done here) to join in the taxonomy tables to the query.

Change History (3)

comment:1 @sambauers3 years ago

The argument list got a bit munged there. The last two arguments should have double underscores after "category". Here is the relevant link in the codex to how WP_Query works with these arguments:

http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters

That is the argument usage I have followed for this patch.

comment:2 @helenyhou3 years ago

  • Description modified (diff)
Note: See TracTickets for help on using tickets.