WordPress.org

Support

Support » Themes and Templates » Tax and Term Conditional Statement

Tax and Term Conditional Statement

  • emaildano

    @emaildano

    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!

Viewing 2 replies - 1 through 2 (of 2 total)
  • emaildano

    @emaildano

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

    emaildano

    @emaildano

    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!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Tax and Term Conditional Statement’ is closed to new replies.