tax_query clobbers tag and category
|Reported by:||wonderboymusic||Owned by:||wonderboymusic|
The main query should return a tag or category as its queried object if tax_query is applied to a tag or category archive page. It currently returns the first term derived from the WP_Query->tax_query->queries array which does not include the tag or category as a term in the request. WP_Query->tax_query->queries is a portion of the request, but not the request. Because WP_Query sets is_tag and is_category flags, they have to be captured before dealing with is_tax
The result of this bug is that theme functions return the wrong data because the wrong term is returned with get_queried_object.
Real world example: at eMusic, we pass regions into pre_get_posts to regionalize the content that is returned. On a tag page, if you are in the US, we pass the regions "ALL" and "US" to make sure you are looking at appropriate content. Here's what the title for the archives looks like - (spoiler: It's "ALL" when it should be "Daily Download"):
I am attaching a patch.
Change History (20)
in reply to:
4 years ago
- Owner set to wonderboymusic
- Resolution set to fixed
- Status changed from new to closed