[wp-trac] [WordPress Trac] #20767: tax_query clobbers tag and category
WordPress Trac
wp-trac at lists.automattic.com
Sun May 27 21:19:56 UTC 2012
#20767: tax_query clobbers tag and category
----------------------------+-----------------------------
Reporter: wonderboymusic | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version: 3.4
Severity: major | Keywords: has-patch
----------------------------+-----------------------------
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"):
http://www.emusic.com/17dots/topics/daily-download/
I am attaching a patch.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/20767>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list