jmccole83
1/3/2019 - 2:54 AM

ACF get the row index

This function will return the row index starting from 1 (first row = 1, second row =2, etc).

<?php if( have_rows('slides') ): ?>
  <?php while( have_rows('slides') ): the_row(); ?>
    <div class="accordion" id="accordion-<?php echo get_row_index(); ?>">
      <h3><?php the_sub_field('title'); ?></h3>
      <?php the_sub_field('text'); ?>
    </div>
  <?php endwhile; ?>
<?php endif; ?>