Home › Forums › Add-ons › Repeater Field › Limiting Results from Repeater Field › Reply To: Limiting Results from Repeater Field
Hi @xranerx
A simple counter can be used to limit the fields. I have taken the liberty of neatening your code and adding in a limiter of 4 rows:
<?php if(get_field('show_dates', 'option')):
$i = 0;
?>
<ul>
<?php while( has_sub_field('show_dates', 'option') ):
$i++;
if( $i > 4 )
{
break;
}
?>
<li><a href="<?php site_url(); ?>/show-dates"><?php the_sub_field('show_date_table_city');?></a></li>
<?php endwhile; ?>
</ul>
<?php else: ?>
<p>Show dates to be announced soon.</p>
<?php endif; ?>
Please continue to practice your PHP and write clean code that does not have mixed styles.
Good luck
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.