我的 wordpress 页面中有 post_type = 投资组合,通过这段代码,我得到了每个帖子的类别:
$terms = get_the_terms( $post->ID, 'portfolio_category' );
foreach ( $terms as $term ) {
$draught_links[] = $term->name;
}
$on_draught = join( ", ", $draught_links );
但它不能正常工作。它显示当前帖子的类别以及之前所有帖子的类别。如何解决?