Hi All,
Just wondering if anybody could give me some advice/help please.
I need to add a class to an image tag, if it is the last field within the repeater. I’ve managed to add a class to the first image within the repeater field, but struggling to do the last. This is my current code:
<?php if( have_rows('accreditations', 'option') ): $count = 0; ?>
<?php while ( have_rows('accreditations', 'option') ) : the_row(); ?>
<div class="col-lg-2 col-md-2 col-sm-6">
<?php $logo = get_sub_field('logo'); if( !empty($logo) ): ?>
<img <?php if (!$count) { ?> class="first-logo"<?php } ?> class="img-fluid " src="<?php echo $logo['url']; ?>" alt="<?php echo $logo['alt']; ?>" />
<?php endif; ?>
</div><!--End Columns-->
<?php
$count++;
endwhile;
else :
endif;
?>
Have you considered using :last-child?