WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.


share|improve this question
up vote 2 down vote accepted


function has_type( $type, $_post = null ) {
    if ( empty( $type) )
        return false;

    if ( $_post )
        $_post = get_post( $_post );
        $_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;


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

Hope this helps.

share|improve this answer
worked perfectly, thanks – pete_schuster Feb 18 '11 at 16:07
Glad i could help – Bainternet Feb 18 '11 at 16:14

In WP 3.1, you have the handy has_term() function, found in wp-includes/category-template.php.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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