Hi!
I want to be able to put in how many rows as possible into a repeater field, but I just want to display 5 at the time and randomize these 5 fields every time the page load.
So what I’m looking for is to random repeater field, but limit the output to maximum 5.
I have tried to shuffle between answers from how to random and how to limit but can’t get it to work.
So now I have a code that works, that output maximum 5 rows, even though I have 20 fields.
So how can I random this fields now, but limit to 5?
My code right now is: `<? if( get_field(‘referenser’) ): $i = 0; ?>
<?php while( has_sub_field(‘referenser’) ): $i++;
if( $i > 5 )
{
break;
}
?>
<?php $bilder = wp_get_attachment_image_src(get_sub_field(‘referensens_logotype’), ‘full’); ?>
<div class=”referens”><img src=”<?php echo $bilder[0]; ?>”></div>
<?php endwhile; ?>
<?php endif; ?>`