Support

Account

Home Forums Add-ons Repeater Field Repeater – Only Display First 3 Rows Reply To: Repeater – Only Display First 3 Rows

  • For anyone stumbling on this answer, please be aware that there’s an unclosed php tag in the snippet provided. Here’s the updated code

    <?php
    if( have_rows('latest_offers', 'options') ):
     	$i = 0;
        while ( have_rows('latest_offers', 'options') ) : the_row(); ?>
    		<?php $i++; ?>
    		<?php if( $i > 3 ): ?>
    			<?php break; ?>
    		<?php endif; ?>
    		
    		<a href="<?php the_sub_field('page_link'); ?>" class="hot">
    			<div class="img"><img src="<?php the_sub_field('brand_logo'); ?>" alt=""></div>
    			<div class="text">
    				<div class="smlltxt"><?php the_sub_field('heading'); ?></div>
    				<div class="num"><?php the_sub_field('price'); ?></div>
    				<div class="txt"><?php the_sub_field('description'); ?></div>
    			</div>
    			<img src="<?php echo get_template_directory_uri(); ?>/img/hot.png" alt="" class="hot_img">
    		</a>
    	
        <?php endwhile;
     
    else :
    
    endif;
    ?>