By
05/13/2016   Comments Off on ACF repeater field code

View all snippets

Here’s the Advanced Custom Field code for a repeater field:

<?php if( have_rows('slider') ): ?>
   <?php // stuff before repeater ?>
   <ul>
   <?php while( have_rows('slider') ): the_row();?> 
   <?php // vars
      $link = get_sub_field('link');
   ?>

   <?php // stuff to be repeated ?>
    <li href="<?php echo $link; ?>"></li>

   <?php endwhile; ?>
   <?php // stuff after repeater ?>
   </ul>
<?php endif; ?>