Support

Account

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