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