Check If Field Exists In Any Repeater Sub Field

Checking the value of an ACF repeater’s sub field outside the loop is possible with this code. It’s as simple as checking inside the loop and fetching the boolean result out.

Check the value of a sub field, outside the while loop

Use the code below to check the value of a sub field, located outside the while loop. Be sure to adjust the repeater and sub field accordingly.

$found = false;
$value = 'Your value';
while ( have_rows( 'your_repeater_field' ) ) : the_row();
     if ( get_sub_field( 'your_sub_field' ) == $value ) :
          $found = true;
     endif;
endwhile;

if ( $found ) {
     // True
} else {
     // False
}