How to add Text before my Custom Term and hide it when empty
This is my code:
?php
$terms = get_the_terms( $post-ID , 'this_is_custom' );
$links = [];
foreach ( $terms as $term ) {
$term_link = get_term_link( $term, 'this_is_custom' );
if( !is_wp_error( $term_link ) ) {
$links[] = 'a href=' . $term_link . '' . $term-name . '/a';
}
}
echo implode(',nbsp;', $links);
?
The result are:
Mango, Orange, Banana
What it wants to achieve is:
Tag: Mango, Orange, Banana
How can I display the word Tag: and hide it when there is no Term inside current post?
Sorry for my English. I hope you understand.
Thanks for your answer, I really appreciated.
Topic conditional-tags template-tags tags php custom-taxonomy Wordpress
Category Web