Support

Account

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>