Home › Forums › Add-ons › Repeater Field › Adding class \'active\' to a repeater.
Hi there,
I was wondering could anyone help me.
I have created a carousel slider with the images being taken in via repeater fields. When the image is ‘active’ I need to put have a class around the active image. I need this because when the active image is being shown, I need text to be shown along with it. The other images on the carousel will not be shown.
Any help would be much appreciated!
Thanks,
Tiarnan
<div class="quote-section">
<div class="slider4">
<?php if( have_rows('quote_slider') ):
while ( have_rows('quote_slider') ) : the_row(); ?>
<li class="slide">
<div class="quote"><?php the_sub_field('quote'); ?></div>
<div class="name"><?php the_sub_field('name'); ?></div>
<div class="image"><img src="<?php the_sub_field('image'); ?>" /></div>
</li>
<?php endwhile;
else : endif; ?>
</div>
</div>

what is your goal?
first should be possible with php without big problems. use something like that:
<div class="quote-section">
<div class="slider4">
<?php if( have_rows('quote_slider') ):
$img_count=1;
while ( have_rows('quote_slider') ) : the_row();
if ($img_count == 1) {
?>
<li class="slide active">
<div class="quote"><?php the_sub_field('quote'); ?></div>
<div class="name"><?php the_sub_field('name'); ?></div>
<div class="image"><img src="<?php the_sub_field('image'); ?>" /></div>
</li>
<?php } else {?>
<li class="slide">
<div class="quote"><?php the_sub_field('quote'); ?></div>
<div class="name"><?php the_sub_field('name'); ?></div>
<div class="image"><img src="<?php the_sub_field('image'); ?>" /></div>
</li>
<?php }
$img_count++; ?>
<?php endwhile;
else : endif; ?>
</div>
</div>
second is/shouldbe part of your slider js, and there i could not help you
The topic ‘Adding class \'active\' to a repeater.’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.