Support

Account

Home Forums Add-ons Repeater Field How does one target a specific row in a repeater field with sub fields Reply To: How does one target a specific row in a repeater field with sub fields

  • I’d add a count to the loop and assign the count number as an id/class.

    E.g:

    <?php	
    	$counter = 0;  //this sets up the counter starting at 0
     
    	if(get_field( 'repeater_field' )) {
    		echo '<div>';
    		while(has_sub_field('repeater_field')) {
    			$counter++; // add one per row
    			echo '<div id="row-' . $counter . '"> STUFF </div>';
    		}
    		echo '</div>';
    	} 
    ?>