First you need to store a variable with a random number no greater than the amount of rows in the repeater:
$rand_max = count(get_field('testimonials'));
Then you need to loop through the repeater rows with an incrementing key and if the key equals the random number, then display the row:
<?php
$rand_max = count(get_field('testimonials'));
$i = 0;
?>
<?php while(the_repeater_field('testimonials')): ?>
<?php if($rand_max == $i): ?>
<em id="__mceDel">
<?php the_sub_field('name'); ?>
...
<?php endif; ?>
<?php $i++; ?>
<?php endwhile; ?></em>
Revisions
- May 2, 2013 @ 11:17:49 [Current Revision] by PeterLugg
- May 2, 2013 @ 11:17:16 by PeterLugg
No comments yet.