When your website means business.

ACF, PHP | Type: PHPRandom order with ACF Repeater field

Repeatable fields can be stored in an array using PHP, and using the PHP shuffle() function, we can shuffle the array elements.

$customer_reviews = get_field('customer_reviews');
shuffle($customer_reviews); // magic happens here :)
if( have_rows('customer_reviews') ):
    foreach( $customer_reviews as $customer_review ):
        $review_title = $customer_review['review_title'];
        $review_description = $customer_review['review_description'];
        $review_star_ratings = $customer_review['review_star_ratings'];
        echo '<h2>'.$review_title.'</h2>';
        echo '<p>'.$review_description.'</p>';
        echo '<strong>Stars: '.$review_star_ratings.'</strong>';
        echo '<hr>';

Reference Links

We use cookies in order to give you the best possible experience on our website. By continuing to use this site, you agree to our use of cookies.
Cookies Notice