Struggling to find out how to achieve this, if it is at all possible. The equivalent of is_category but for a custom taxonomy I've set up. The taxonomy category if which being Taxonomy Name with 2 taxonomies: Taxonomy One and Taxonomy Two. But this:

<?php if ( has_term('taxonomy-one' ) ) {?>
    <div class="test" style="color: red"><?php the_field('field_name'); ?></div>
<?php } elseif ( has_term('taxonomy-two' ) ) {?>
    <div class="test" style="color: green"><?php the_field('field_name'); ?></div>
<?php } ?>

There doesn't seem to be any documentation for this either so I'm not at all sure if it's possible, I'm hoping so though, any suggestions would be greatly appreciated!

1 Answer 1


I'm pretty sure you shouldn't use negation in your conditions... If you check ! is_tax... it will be true not only for other taxonomy pages, but also for singular pages, and any other...

So it should look like this:

<?php if ( is_tax('taxonomy-name','taxonomy-one' ) ) {?>
    <div class="test" style="color: red"><?php the_field('field_name'); ?></div>
<?php } elseif ( is_tax('taxonomy-name','taxonomy-two' ) ) {?>
    <div class="test" style="color: green"><?php the_field('field_name'); ?></div>
<?php } ?>

And about lack of documentation... I have no idea where have you looked for, but there is codex page for is_tax: http://codex.wordpress.org/Function_Reference/is_tax ;)

PS. If you want to check if given post is assigned to term, then you should use has_term function.

  • thanks for that! I have read that in the codex before, but I'm not actually looking to put this code in a taxonomy archive, but in a custom post type archive that I have added the custom taxonomies too :) I have tried the above code you suggested before as well and it didn't work :( Jul 12, 2013 at 20:19
  • is_tax tells you if it's taxonomy archive. Custom post type archive is not a taxonomy archive (like posts index is not category archive)... So I'm not exactly sure what do you want to achieve...? Jul 12, 2013 at 20:32
  • ah right, I didn't realise that, I'm new to taxonomies, apologies. What I was trying to achieve was to check if the post was in one taxonomy or the other. If in one the text in the post archive will be red if in the other the text in the post archive will be green. Jul 12, 2013 at 20:36
  • No problem. You should use has_term (codex.wordpress.org/Function_Reference/has_term) then. Jul 12, 2013 at 20:38
  • I've edited my question with the has_term still doesn't seem to work though, nothing showing up at all? Jul 12, 2013 at 21:09

Not the answer you're looking for? Browse other questions tagged or ask your own question.