[wp-trac] [WordPress Trac] #30846: Custom query using tag__in sets query_var tag_id
WordPress Trac
noreply at wordpress.org
Fri Dec 26 21:51:04 UTC 2014
#30846: Custom query using tag__in sets query_var tag_id
-------------------------------+------------------------------
Reporter: philbirnie | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Taxonomy | Version: 4.1
Severity: normal | Resolution:
Keywords: reporter-feedback | Focuses:
-------------------------------+------------------------------
Changes (by boonebgorges):
* keywords: => reporter-feedback
Comment:
philbirnie - Thanks for the detailed report.
You're correct that `tag_id` gets set to the first member of `tag__in`.
This happens primarily for backward compatibility, to ensure that the
`tag_id` query var is always backfilled when viewing a taxonomy archive,
in case themes attempt to reference it directly when (eg) setting up page
titles. However, it's not referenced when building the SQL query itself.
`WP_Query` converts all the query_vars passed directly to the class into a
single unified `tax_query`; see
https://core.trac.wordpress.org/browser/trunk/src/wp-
includes/query.php#L1951. This tax query correctly recognizes the
`tag__in` param. The `tag_id` backfilling happens afterward:
https://core.trac.wordpress.org/browser/trunk/src/wp-
includes/query.php#L2709
The attached unit test [attachment:30846.test.diff] shows that this is
working properly. Can you look at the logic there to make sure I'm
understanding your report correctly?
Double check to make sure you don't have any plugins or other
customizations doing anything odd here. If you continue to have the
problem even without any plugins, please share more detail about exactly
*where* you're generating the query - the only possibility I can see is
that there's something funny going on where you're trying to do a
taxonomy-related query while on a single term's taxonomy archive page, or
something like that.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/30846#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list