Make WordPress Core

Opened 10 years ago

Last modified 2 years ago

#20597 new enhancement

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

Reported by: sambauers Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.4
Component: Comments Keywords: needs-patch needs-unit-tests
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)

#1 @sambauers
10 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:


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

#2 @helenyhou
10 years ago

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