WordPress.org

Ready to get started?Download WordPress

Forums

Tax and Term Conditional Statement (3 posts)

  1. emaildano
    Member
    Posted 6 months ago #

    Hey!

    I've been reading the Codex docs on this and I cannot figure it out.

    I'd like create a condition for a taxonomy and term. The Taxonomy is 'locations' and the term is 'University City'.

    Here's what I've come up with but I cannot get it working.

    <?php
    
    if ( is_tax( 'locations', 'University City' )   ) {    
    
        echo 'University City';
    
    } else { 
    
        echo 'Not University City';
    }	
    
    ?>

    Here's the doc I've been reading: http://codex.wordpress.org/Function_Reference/is_tax

    Any suggestions?

    Thanks!

  2. emaildano
    Member
    Posted 6 months ago #

    Also, I've tried the term slug ( 'university-city' ) with no success.

  3. emaildano
    Member
    Posted 6 months ago #

    Update

    Just tried this and it works:

    <?php
    
    if ( is_single( 'University City' )   ) {    
    
        echo 'University City';
    
    } else { 
    
        echo 'Not University City';
    }	
    
    ?>

    This will do for now, but I'd like to get my first question sorted out.

    Thanks!

Reply

You must log in to post.

About this Topic