When your website means business.

ACF | Type: PHPNested Repeater

How to display a repeater within a repeater (with conditionals).

if( have_rows('schools_in_region') ) : // check for rows (parent repeater)
	echo '

<div class="schoolist">';
	while( have_rows('schools_in_region') ): the_row(); // loop through rows (parent repeater)
		$district = get_sub_field('school_district');
		echo '

<h4>'.$district.'</h4>

';
		if( have_rows('school') ) : // check for subrepeater
			while( have_rows('school') ): the_row(); // loop through subrepeater
				$school = get_sub_field('school_name');
				$mascot = get_sub_field('mascot_name');
				$link = get_sub_field('school_website');
				if ($school) {
				echo '
';
				if ($link){
					echo '<a href="'.$link.'" target="_blank" rel="noreferrer noopener">';
				}
				echo $school;
				if ($link){
				echo '</a>';
				}
				if ($mascot) {
				echo ' ('.$mascot.')';
				}
				echo '
';
				}
			endwhile; //end subrepeater loop
		endif; //end subrepeater
	endwhile; //end parent repeater loop
	echo '</div>

';
endif; //end parent repeater