How do I get the slug of a custom taxonomy category of a post?

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?

Related posts

Leave a Reply

1 comment

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