Home › Forums › ACF PRO › Randomize Repeater Rows… › Reply To: Randomize Repeater Rows…
I’ve actually never used array_rand before so I did some testing. Basically what I found was that no matter how many items you want returned, the keys are always returned in order. So it you pick 3 of 5
you might get 0, 2, 4
but never 4, 0, 2
. So when selecting the 5 of 5
it will always return 0, 1, 2, 3, 4
shuffle is what you’re looking for
$repeater = get_field('contributors_grid','option');
shuffle($repeater);
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.