Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

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;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.