• Forgive me if this is obvious but I’ve only just started dabbling with custom post types and custom taxonomies. I’m struggling with this. When I was using category’s I would use the code

    <?php
    if ( in_category( 'countryside' )) {
            echo 'Works';
    } else {
    	// Show nothing
    }
    ?>

    To check if a post was in the category “countryside” but how do I do the same with taxonomies?

    My Hierachal taxonomy is called “Collections” and within that I have the category of “Countryside” so I’m wanting to show something if the post is in “Countryside” but show something else if not.

    Any help would be greatly appreciated before I pull all of my hair out?!?!

Viewing 1 replies (of 1 total)
  • Thread Starter greencode

    (@greencode)

    Ah! Looks like I’ve found the answer:

    <?php
    if ( has_term( 'countryside','collection' )) {
            echo 'Works';
    } else {
    	echo 'Does not work!';
    }
    ?>
Viewing 1 replies (of 1 total)
  • The topic ‘if in taxonomy’ is closed to new replies.