When separating the categories, the "," appears in the last category. e.g Category1, Category2,
I am using this function.
// MultiNetwork
function MultiNetwork() {
global $post;
$terms = get_the_terms( $post->ID, 'networks');
$count = 0;
foreach ( $terms as $term ){
if ($count <= 1) {
$firstTerm = $term;
$term_link = get_category_link($firstTerm->term_id);
echo '<span class="network"><a href="' . $term_link . '" rel="tag">' . $firstTerm->name . '</a></span>',',';
$count++;
}
}
}
I would like it to stay Category1, Category2
Intente usando explode e implode.