Support

Account

Home Forums ACF PRO Unique identifier for each flexible field? Reply To: Unique identifier for each flexible field?

  • I solved the problem by creating a php counter http://stackoverflow.com/questions/11869142/how-can-i-make-a-php-counter

    column-block-# where # is 1, 2, 3, 4 etc. until the repeat ends. see code below.

    
    // check if the nested repeater field has rows of data
            	if( have_rows('column_repeater') ):
    
    			 	echo '<ul class="small-block-grid-' . $number_columns . '">';
    
    			 	// loop through the rows of data
    			    while ( have_rows('column_repeater') ) : the_row();
    
    					if (empty($counter)){
    					   $counter = 'column-block-' . 1;
    					}else{
    					   $counter++;
    					}
    
    				$content = get_sub_field ('column_content');
    
    					echo '<li><div class="' . $counter . '">' . $content . '</div></li>';
    
    				endwhile;
    
    				echo '</ul>';
    
    			endif;