DEV Community

Duane Doogan
Duane Doogan

Posted on

ACF Repeater with Separator

Comma separated ACF Repeater except for last row.

<?php $variable = get_sub_field('repeater_field'); ?>
<?php if ( $variable ): ?>
<?php $notLast = $variable;
      foreach ($variable as $v ): ?>
        <?php the_field('field_name', $v); if (next($notLast)) { echo ','; } ?>
<?php endforeach; ?>
<?php endif; ?>
Enter fullscreen mode Exit fullscreen mode

Discussion (0)