Opened 15 years ago
Closed 15 years ago
#11904 closed enhancement (fixed)
Conditional tag for terms
Reported by: | pavelevap | Owned by: | dd32 |
---|---|---|---|
Milestone: | 3.0 | Priority: | normal |
Severity: | normal | Version: | 2.9.1 |
Component: | Taxonomy | Keywords: | has-patch tested commit |
Focuses: | Cc: |
Description
Conditional tag for terms would be very helpfull. There is is_tax() for taxonomies but from WordPress 2.9 it does not work for terms in taxonomies. So any function is_tax_term() would be fine (see http://core.trac.wordpress.org/ticket/10721).
Attachments (3)
Change History (20)
#3
@
15 years ago
- Component changed from General to Taxonomy
- Keywords has-patch added
- Owner changed from filosofo to ryan
#5
in reply to:
↑ 4
@
15 years ago
Replying to scribu:
I don't think $term should be optional.
Why not? It's parallel to is_category
, for which the specific category is optional.
function is_category($category = '') { return is_tax_term('category', $category); }
#6
follow-up:
↓ 8
@
15 years ago
How about we add $term as an optional parameter to is_tax(), directly?
It seems more intuitive.
#7
follow-up:
↓ 9
@
15 years ago
I was actually going to suggest we add an optional parameter $taxonomy to is_term()... but, well:
function is_term($term, $taxonomy = '', $parent = 0)
Why isn't that sufficient?
#8
in reply to:
↑ 6
@
15 years ago
Replying to scribu:
How about we add $term as an optional parameter to is_tax(), directly?
It seems more intuitive.
I'm good with that. Second patch does that.
#9
in reply to:
↑ 7
@
15 years ago
function is_term($term, $taxonomy = '', $parent = 0)
Clearly misread the ticket here :(
I'm +1 on the second patch.
#11
@
15 years ago
is_tax.11904.2.diff validates the taxonomy array upfront, to prevent a very unlikely edge case.
Also reduced the nesting level a bit.
#14
@
15 years ago
I removed most of the nesting and seperated it into 2 branches.
re-open if anyone can see a mistake in the conversion.
#16
@
15 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
Re-opening, I've reverted part of this, allowing is_tax() return true for Tags and Categories has side effects where core expects is_Tax() to be false for those taxonomies.
Whilst i agree that Tags and categories should return true, More work needs to be done to make it compatible with the rest of core.
Attached patch adds conditional
is_tax_term([taxonomy], [term])
.Tested with custom taxonomies, categories, and post tags.