Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#20590 closed defect (bug) (fixed)

is_tax() with term parameter returns true for any taxonomy with that term

Reported by: petercarlill's profile petercarlill Owned by:
Milestone: 3.5 Priority: normal
Severity: minor Version:
Component: Taxonomy Keywords: has-patch needs-unit-tests
Focuses: Cc:


I have two custom taxonomies, 'body' and 'operations', assigned to different custom post types.

Both taxonomies contain the term 'shoulder'

is_tax('operations','shoulder') returns true both when viewing the 'shoulder' archive for the taxonomy 'operations' and when viewing the archive page for the term 'shoulder' in the taxonomy 'Body-Parts'

Therefore, is_tax() is returning true for the term, and ignoring which taxonomy it is in.

The only way I can get it to return true only when viewing the 'shoulder' archive for 'operations' is by is_tax( 'operations', 'shoulder') && is_tax('operations')

Version is 3.3.2

Attachments (1)

query-is-tax-fix.diff (886 bytes) - added by wonderboymusic 12 years ago.

Download all attachments as: .zip

Change History (8)

#1 @wonderboymusic
12 years ago

Yep - WP_Query::is_tax() only does the tax check if you didn't pass a term - I have a fix - patch attached

#2 @SergeyBiryukov
12 years ago

  • Keywords has-patch needs-unit-tests added

#3 @wonderboymusic
12 years ago

  • Milestone changed from Awaiting Review to 3.5

#4 @nacin
12 years ago

In [21836]:

Check that the taxonomy matches when calling is_tax() with only a taxonomy argument. props wonderboymusic, see #20590.

#5 @nacin
12 years ago

Some quick unit tests for this would be awesome.

#6 @ryan
12 years ago

Unit tests for this are a pain.

#7 @ryan
12 years ago

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.