Home Forums Add-ons Repeater Field Dynamic Repeater Fields with Titles Reply To: Dynamic Repeater Fields with Titles

  • I got to it in the end….

    Here’s my working solution:

    $all_attributes = array();
    $filter_attributes = array();
    if (have_rows('logos')): while (have_rows('logos')) : the_row(); 
        $attributes = get_sub_field_object('partner'); 
        $values[] = get_sub_field('partner'); 
        if($values) {
            foreach ($values as $value) 
                $all_attributes[] = $value; /* Save ALL values */
     endwhile; endif;
    /* use array_unique to remove duplicates from the array */
    $filter_attributes = array_unique ($all_attributes);
    <?php $colors = $filter_attributes;
    	foreach ($colors as $color) {
    	    global $b;
    		echo "<h3>" . ucfirst($color) . "</h3>";
    		echo '<div class="row">';
    		while ( have_rows('logos') ) : the_row();
    		    if(get_sub_field('partner') == "{$color}"):
    				// display the repeater sub field values
    				echo    '<div class="col-sm-6 col-md-3 text-center py-3" id="'.$b.'">
    						 <a href="' . get_sub_field('website') .'"><img src="' .get_sub_field('logo') . '" /></a>
    	echo '</div>';