WordPress.org

Make WordPress Core

Opened 9 months ago

Closed 8 months 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:

Description

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.

http://core.trac.wordpress.org/browser/tags/3.5.2/wp-includes/query.php#L2212

Change History (7)

comment:1 maxaud9 months ago

  • Cc dustin@… added

comment:3 follow-up: leewillis779 months ago

This was added in http://core.trac.wordpress.org/changeset/17504. The commit message claims it fixes http://core.trac.wordpress.org/ticket/16793 but actually seems completely unrelated to that ticket. So, probably not as straightforward as just removing the condition.

Version 0, edited 9 months ago by leewillis77 (next)

comment:4 in reply to: ↑ 3 ocean909 months ago

Replying to leewillis77:

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

Yes. The ticket is #16703.

comment:5 SergeyBiryukov9 months ago

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

comment:6 maxaud9 months 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 wonderboymusic8 months 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.