Opened 13 months ago

Closed 7 months ago

#20590 closed defect (bug) (fixed)

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

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

Description

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 9 months ago.

Download all attachments as: .zip

Change History (8)

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

  • Keywords has-patch needs-unit-tests added
  • Milestone changed from Awaiting Review to 3.5

In [21836]:

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

Some quick unit tests for this would be awesome.

Unit tests for this are a pain.

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