name. ',';
<?php
$terms = get_field('genre');
if( $terms ):
?>
<?php foreach( $terms as $term ): ?>
<a href="<?php echo get_term_link( $term ); ?>"><?php echo $term->name. ','; ?></a>
<?php endforeach; ?>
<?php
$terms = get_field('genre');
$count = count($terms);
?>
<?php foreach( $terms as $i => $term ): ?>
<a href="<?= get_term_link( $term ); ?>">
<?= $term->name ?><php if($count-1 > $i): ?>,<?php endif ?>
</a>
<?php endforeach; ?>