Support

Account

Home Forums Front-end Issues Help with object values within repeater field Reply To: Help with object values within repeater field

  • Hey John,

    Thanks for the advice. I’ve changed my code to the below, and the icon now works, however the loop seems to break after the first record. There should be 3 records, but I’m now only getting one record in the loop. What am I missing or doing wrong?

    
    <?php if( have_rows('unique_selling_points') ): ?>
    
    		<div class="wrapper">
    
    			<div class="usp-list equal-heights">
    
    				<?php
    				$n = 0;
    				while( have_rows('unique_selling_points') ): the_row();
    					$n++;
    
    					$icon = get_sub_field('icon');
    					$heading = get_sub_field('heading');
    					$intro = get_sub_field('intro');
    					$text = get_sub_field('text');
    					?>
    					<article class="unit">
    						<?php
    						if ($icon):
    							$post = $icon;
    							setup_postdata($post);
    							?>
    							<i class="has-circle bg-brand2">
    			                    <svg class="icon-<?php the_field('css'); ?>">
    			                        <use xlink:href="<?php echo get_template_directory_uri(); ?>/images/icons/icons.svg#icon-<?php the_field('css'); ?>"></use>
    			                    </svg>
    			                </i>
    						    	<?php
    						    wp_reset_postdata();
    						endif;
    				        ?>
    						<h1 class="heading4"><?php echo $heading; ?></h1>
    						<p class="intro"><?php echo $intro; ?></p>
    						<?php if( $text ): ?>
    							<div id="usp-<?php echo $n?>" class="reveal">
    								<?php echo $text; ?>
    							</div>
    							<a href="javascript:void(0);" title="Read more" class="btn hover2">
    								Read more
    								<i class="down">
    				                    <svg class="icon-arrow-down">
    				                        <use xlink:href="<?php echo get_template_directory_uri(); ?>/images/icons/icons.svg#icon-arrow-down"></use>
    				                    </svg>
    				                </i>
    							</a>
    						<?php endif; ?>
    					</article>
    
    				<?php endwhile; ?>
    
    			</div>
    
    		</div>
    
    	<?php endif; ?>