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?
use this code for specific category
Chnage the number of post and category ID….