WordPress if in term*

i am having trouble with conditional and custom post types.

i would like to set something up like this:

Read More
<?php 
if (in_term('products')){
include ('products.php'); 
}elseif (in_term('downloads')){
include ('downloads.php'); 
}else {
    //Nothing Happens
}?>

Obviously this doesnt work, but if there is an alternative anybody knows then please share 🙂

Thank you,

Dan

Related posts

Leave a Reply

1 comment

  1. http://codex.wordpress.org/Function_Reference/has_term

    So…

    <?php 
    if ( has_term('products', 'your_custom_taxonomy', $post ) ) 
    {
        get_template_part('products'); 
    }
    elseif ( has_term( 'downloads', 'your_custom_taxonomy', $post ) )
    {
        get_template_part('downloads'); 
    }
    ?>
    

    Change your_custom_taxonomy to whatever that taxonomy name is. I changed include to get_template_part. If this is found in a theme file, that’s the correct function to use. If it’s in a plugin, feel free to change it back.