ACF Repeater Loop Ready for HTML

Why is this needed?

I use this loop all the time and I always have to close out each line of PHP in order to pepper it with my markup. So this is just a way to save a little time.

<?php if( have_rows('repeater_field_name') ): ?>
   <?php while ( have_rows('repeater_field_name') ) : the_row(); ?>
      <?php the_sub_field('sub_field_name'); ?>
   <?php endwhile; ?>
<?php else: ?>
   <!-- there are no rows -->
<?php endif; ?>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s