Make WordPress Core

Opened 2 years ago

Closed 2 years ago

#24819 closed defect (bug) (wontfix)

tax_query not executed on single post/page/etc

Reported by: maxaud Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.5.2
Component: Query Keywords:
Focuses: Cc:


in /wp-includes/query.php on line 2212 there is an if statement that blocks a tax_query filter from executing if is_single is true.

In my particular use case, I need to use tax_query on single pages and posts and am surprised this is being blocked..

My particular WordPress stops certain pages from displaying under certain circumstances dependent upon what term they belong to in a custom taxonomy. I see this ability becoming ever more common the more people use WordPress to create web apps and CMS platforms.


Change History (7)

comment:1 @maxaud2 years ago

  • Cc dustin@… added

comment:3 follow-up: @leewillis772 years ago

This was added in [17504]. The commit message claims it fixes #16793 but actually seems completely unrelated to that ticket. So, probably not as straightforward as just removing the condition.

Last edited 2 years ago by ocean90 (previous) (diff)

comment:4 in reply to: ↑ 3 @ocean902 years ago

Replying to leewillis77:

.. fixes #16793 but actually seems seems completely unrelated to that ticket.

Yes. The ticket is #16703.

comment:5 @SergeyBiryukov2 years ago

Looking at #16703, this sounds like a wontfix to me.

comment:6 @maxaud2 years ago

Instead of removing the if statement, what about checking to see if a tax_query is set?

I managed to get around it by duplicating the code to my own class and filtering the where and join clauses but obviously I expected my tax_query to work on singular post/page otherwise I would have used is_singular() to check before applying tax_query.

I would imagine changing it now would most likely mess with other people's working code because they most likely don't check for !is_singular()

comment:7 @wonderboymusic2 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Too edge case for such an impactful change to query

Note: See TracTickets for help on using tickets.