Want to display unlinked terms that the current entry has for a specific custom taxonomy within the loop?
Here’s the sample code for that.
// Displays comma separated Staff Position taxonomy terms. | |
function sk_entry_terms() { | |
$terms = get_the_terms( get_the_ID() , 'staff-position' ); | |
if ( ! empty( $terms ) ) { | |
echo '<p class="entry-meta"><span class="entry-terms">'; | |
foreach ( $terms as $term ) { | |
$entry_terms .= $term->name . ', '; | |
} | |
$entry_terms = rtrim( $entry_terms, ', ' ); | |
echo $entry_terms . '</span></p>'; | |
} | |
} |
Replace staff-position with your custom taxonomy.
and the function call:
<?php echo sk_entry_terms(); ?> |
Slightly different method: http://codex.wordpress.org/Function_Reference/get_the_terms#A_Basic_Example