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;
?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.