Opened 13 years ago
Last modified 6 years ago
#20597 new enhancement
Allow WP_Comment_Query::query to filter by category
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 )
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.
Attachments (1)
Change History (5)
#3
@
10 years ago
- Keywords needs-patch added; has-patch needs-testing removed
- Milestone changed from Awaiting Review to Future Release
Thanks for the patch, sambauers.
Adding these table joins into WP_Comment_Query
is pretty unappealing. In WP_Query
, all (or at least most) of the category query logic has been moved to WP_Tax_Query
. So, if we were going to add something like this, we'd want to do it with WP_Tax_Query
instead of by building the SQL like this. I guess the relevant argument for WP_Comment_Query
would then be something like 'post_tax_query', since we would want to leave the door open for putting taxonomy on comments at some point in the future.
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.