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 if( have_rows('slides') ): ?>
2 <ul class="slides">
3 <?php while( have_rows('slides') ): the_row();
4 $image = get_sub_field('image');
5 ?>
6 <li>
7 <?php echo wp_get_attachment_image( $image, 'full' ); ?>
8 <p><?php the_sub_field('caption'); ?></p>
9 </li>
10 <?php endwhile; ?>
11 </ul>
12<?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}