如果您想获得自定义分类法逗号分隔列表,那么我们可以使用WordPress内置函数get_the_term_list()
get_the_term_list( $id, $taxonomy, $before, $sep, $after )
$id : Post ID
$taxonomy : Name of taxonomy
$before : Leading text
$sep : String to separate tags
$after : Trailing text
for example,
<?php echo get_the_term_list( $post->ID, \'people\', \'People: \', \', \' ); ?>
或者我们可以一起去
$term_obj_list = get_the_terms( $post->ID, \'taxonomy\' );
$terms_string = join(\', \', wp_list_pluck($term_obj_list, \'name\'));