Home › Forums › Add-ons › Repeater Field › Randomizing Repeater Rows › Reply To: Randomizing Repeater Rows
primary it should work with help of php function shuffle.
but you need to rebuild your code and replace the while loop with a foreach loop to use it.
here is a simple code how to use randomize(shuffle):
<?php
$rows = get_field('repeater_field_name' ); //get all rows
shuffle ($rows); //randomize rows
if($rows) {
foreach($rows as $row) { //print rows
echo $row['sub_field_name'];
echo ' ';
echo $row['sub_field2_name'];
echo '<br>';
}
}
?>
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.