Opened 9 years ago
Last modified 7 weeks ago
#38278 new enhancement
Only query taxonomies assigned to the post types being queried
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Awaiting Review | Priority: | normal |
| Severity: | normal | Version: | 4.7 |
| Component: | Taxonomy | Keywords: | 2nd-opinion needs-patch |
| Focuses: | Cc: |
Description
While working on #31383 (Add WP_Tax_Query support to WP_User_Query), it was brought up that taxonomy queries do not check to see whether the requested taxonomies are registered to the requested post type.
Opening this ticket to discuss further. Should taxonomies always match the queried post_type?
From @boonebgorges on the other ticket:
Here's a way to frame the issue: are we likely to confuse developers if we allow (ie, don't throw errors for) queries like
get_users( ... 'tax_query' => ... 'taxonomy=post_tag' )? Orget_posts( ... 'tax_query' => ... 'taxonomy=some_user_taxonomy' )? Or maybe these queries will just always end up empty? We should think through the possible confusions (or, maybe, lack thereof).
Hey @desrosj,
I just came across this ticket, and the idea of making
WP_Querysmarter feels like something that would appeal to the greater community.Reading through the past comments, the concern about backwards compatibility really stands out. We all know how essential
WP_Queryis, and breaking things is the last thing we want. I'm curious, does everyone agree that's the primary challenge to solve here?If this is something that community wants, what would give us the confidence to move this forward? I know we have unit tests in place for this, but I feel like we should expand on these to help cover this change within the functionality? Or perhaps some performance benchmarks showing the real world impact?
I would love to hear what others also think might be good next steps to tackle this one safely.