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<?php if( have_rows('repeater_field_name') ):
2 while( have_rows('repeater_field_name') ): the_row();
3 $image = get_sub_field('image');
4 endwhile;
5endif; ?>
1<?php if( have_rows('repeater_field_name') ): ?>
2
3 <ul class="slides">
4
5 <?php while( have_rows('repeater_field_name') ): the_row();
6
7 // vars
8 $image = get_sub_field('image');
9 $content = get_sub_field('content');
10 $link = get_sub_field('link');
11
12 ?>
13
14 <li class="slide">
15
16 <?php if( $link ): ?>
17 <a href="<?php echo $link; ?>">
18 <?php endif; ?>
19
20 <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt'] ?>" />
21
22 <?php if( $link ): ?>
23 </a>
24 <?php endif; ?>
25
26 <?php echo $content; ?>
27
28 </li>
29
30 <?php endwhile; ?>
31
32 </ul>
33
34<?php endif; ?>
1<?php
2$rows = get_field('repeater_field_name');
3if( $rows ) {
4 echo '<ul class="slides">';
5 foreach( $rows as $row ) {
6 $image = $row['image'];
7 echo '<li>';
8 echo wp_get_attachment_image( $image, 'full' );
9 echo wpautop( $row['caption'] );
10 echo '</li>';
11 }
12 echo '</ul>';
13}
1<?php
2
3$rows = get_field('repeater_field_name');
4if($rows)
5{
6 echo '<ul>';
7
8 foreach($rows as $row)
9 {
10 echo '<li>sub_field_1 = ' . $row['sub_field_1'] . ', sub_field_2 = ' . $row['sub_field_2'] .', etc</li>';
11 }
12
13 echo '</ul>';
14}
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; ?>