Function like in_category for custom taxonomies

I’m trying to display different content depending on the taxonomy that was been selected. For example I have a taxonomy named Type. Inside that taxonomy I have several different children, one is “Photography.” I’d like the single of a “Photography” to have a full width instead of it having a sidebar. You can do this in regular Posts by using “if in_category(‘photography’)” but I’ve spent the past couple hours trying to rig the_terms and the like to function as such.

Thanks in advance for the help.

Read More

-Pete

Related posts

Leave a Reply

2 comments

  1. Try

    function has_type( $type, $_post = null ) {
        if ( empty( $type) )
            return false;
    
        if ( $_post )
            $_post = get_post( $_post );
        else
            $_post =& $GLOBALS['post'];
    
        if ( !$_post )
            return false;
    
        $r = is_object_in_term( $_post->ID, 'type', $type);
    
        if ( is_wp_error( $r ) )
            return false;
    
        return $r;
    }
    

    Usage:

    <?php if ( has_type( 'Photography' ) ) /* do your thing*/ ?>
    

    Hope this helps.