In my template file, I loop through posts that are categorized either web, print, or marketing in a custom taxonomy portfolio.

How do I echo the slug of each posts category?

1 Answer
1

This shouldn’t be too hard!

$my_terms = get_the_terms( $post->ID, 'portfolio' );
if( $my_terms && !is_wp_error( $my_terms ) ) {
    foreach( $my_terms as $term ) {
        echo $term->slug;
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *