I would like to diplay a set of clonable rows within my template in a random order. There are several videos and only one should be displayed (randomly selected).
At the moment I have to following code:
<?php if( have_rows('video_clonable') ) {
$count = 0;
while( $count < 1 && have_rows('video_clonable') ) {
// increment row
the_row();
// vars
$video = get_sub_field('video');
$hintergrundbild = get_sub_field('hintergrundbild');
?>
<?php if( $video ): ?>
<video muted autoplay>
<source src="<?php echo $video['url'] ?>" type="video/mp4">
Your browser does not support the video tag.
</video>
<?php endif; ?>
<?php
$count++;
}
}
?>
But this code always gets the first row of this while loop. Now I want it to select a row randomly.
Can you help me to transform my function so this can work? Thank you very much for any suggestions and help!
Lukas