Home › Forums › Add-ons › Repeater Field › Add class to first row of repeater › Reply To: Add class to first row of repeater
Add a counter and output the class if the counter is 0 (zero)
<ul class="menu-tabs" role="tablist">
<?php
if( have_rows('rainbow') ):
$count = 0;
while ( have_rows('rainbow') ) :
the_row();
?>
<li role="presentation"<?php
if (!$count) {
?> class="active"<?php
}
?>><a href="#<?php the_sub_field('colour_name'); ?>"
aria-controls="<?php the_sub_field('colour_name'); ?>"
role="tab"
data-toggle="tab"><?php the_sub_field('colour_name'); ?></a>
</li>
<?php
$count++;
endwhile;
endif;
?>
</ul>
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.