wp_get_object_terms 显示当前文章分类列表

wp_get_object_terms 显示当前文章分类列表

<?php
$product_terms = wp_get_object_terms( $post->ID, ‘portfolio_category’ );
if ( ! empty( $product_terms ) ) {
if ( ! is_wp_error( $product_terms ) ) {

foreach( $product_terms as $term ) {

echo ‘<a href=”‘ . get_term_link( $term->slug, ‘portfolio_category’ ) . ‘”>’ . esc_html( $term->name ) . ‘</a>’;
if($term != end($product_terms)) {echo “, “;}
}

}
}?>

滚动至顶部