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

  • Okay I’ve refined it a heap after looking into arrays:

    <?php if( have_rows('logos') ):
    	while( have_rows('logos') ): the_row(); 
    		$select = get_sub_field_object('partner');
    		$value = get_sub_field('partner');
    		$partnerArray = $select['choices']; 
     endif; ?>
    <?php $colors = $partnerArray;
    	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>'; 

    However it will display the titles regardless. If the titles exist, they are shown, even if there are no items on that page. I need them to only show if there are items.