apamphilon

Comma separated taxonomy terms in WordPress

// displays comma separated team specialism taxonomy terms
$terms = get_the_terms( $post->ID , 'team-specialism' );
$entry_terms = '';

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>';
}

Credit


Comments: