I've got post_type = portfolio in my wordpress page, and with this code I get the category of each post:
$terms = get_the_terms( $post->ID, 'portfolio_category' );
foreach ( $terms as $term ) {
$draught_links[] = $term->name;
}
$on_draught = join( ", ", $draught_links );
But it's not working correctly. It shows the category of current post, and of all posts before. How to fix it?
$draught_links =array()just beforeforeach ( $terms as $term )- Mwayi