Hi,
I use a repeater and want to have after every item a backslash. But how I detect the last item? Here I posted the code. Thanks for all help.
Alwin
<?php if( have_rows('services_repeater', $services) ): ?>
<?php while( have_rows('services_repeater', $services) ): the_row();
// vars
$service = get_sub_field('service');
$description = get_sub_field('description');
?>
<span class="hint--bottom" data-hint="<?php echo $description; ?>"><?php echo $service; ?></span> <div id="separator"> / </div>
<?php endwhile; ?>
<?php endif; ?>
Treat the repeater field as an array, you can count the number of values.
<?php if( have_rows('services_repeater', $services) ): ?>
<?php $rowCount = count( get_field('services_repeater', $services) ); //GET THE COUNT ?>
<?php $i = 1; ?>
<?php while( have_rows('services_repeater', $services) ): the_row(); ?>
<?php // vars
$service = get_sub_field('service');
$description = get_sub_field('description');
?>
<span class="hint--bottom" data-hint="<?php echo $description; ?>"><?php echo $service; ?></span>
<?php if($i < $rowCount): ?>
<div id="separator"> / </div>
<?php endif; ?>
<?php $i++; ?>
<?php endwhile; ?>
<?php endif; ?>