1<?php
2
3// ACF REPEATER - BASIC LOOP
4
5// check if the repeater field has rows of data
6if( have_rows('repeater_field_name') ):
7
8 // loop through the rows of data
9 while ( have_rows('repeater_field_name') ) : the_row();
10
11 // display a sub field value
12 the_sub_field('sub_field_name');
13
14 endwhile;
15
16else :
17
18 // no rows found
19
20endif;
21
22?>
1// ACF REPATER - ADVANCED LOOP
2
3<?php if( have_rows('repeater_field_name') ): ?>
4
5 <ul class="slides">
6
7 <?php while( have_rows('repeater_field_name') ): the_row();
8
9 // vars
10 $image = get_sub_field('image');
11 $content = get_sub_field('content');
12 $link = get_sub_field('link');
13
14 ?>
15
16 <li class="slide">
17
18 <?php if( $link ): ?>
19 <a href="<?php echo $link; ?>">
20 <?php endif; ?>
21
22 <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt'] ?>" />
23
24 <?php if( $link ): ?>
25 </a>
26 <?php endif; ?>
27
28 <?php echo $content; ?>
29
30 </li>
31
32 <?php endwhile; ?>
33
34 </ul>
35
36<?php endif; ?>