我不知道如何将else
添加到foreach
!
这是我的代码:
<?php $terms = get_the_terms( $post->ID , 'actor' );
foreach ( $terms as $term ) {
$term_link = get_term_link( $term, 'actor' );
if( is_wp_error( $term_link ) )
continue;
echo '<a href="' . $term_link . '">' . $term->name . '</a>';
}
?>