Powered by Blogger.

Display Custom Taxonomy Name in WordPress


Display Custom Taxonomy Name in WordPress


<?php
// Let's find out if we have taxonomy information to display
    // Something to build our output in
    $taxo_text = '';   

    // Variables to store each of our possible taxonomy lists
    // This one checks for a Product Category classification
    $prodcat_list = get_the_term_list( $post->ID, 'product_category', '', ', ', '' );

    // Add Product Category list if this post was so tagged
    if ( '' != $prodcat_list )
    $taxo_text .= $prodcat_list;
    ?>
This code only builds the list. It displays just one term if there is only one, or a common separated list if there is more than one term.
output: <?php echo $taxo_text; ?>

No comments