Based on your resource page for displaying a random row, the code for doing this has changed to the following. I tried the code above and it didn’t work, but the code stated on the resource page does work to display a random row perfectly. My question now is how to mod it to display a random set of rows, not just one. Note, I tried adding that comma and a number that’s in your example, but it broke the whole output and displays nothing.
<?php $rows = get_field('repeater_field_name' ); // get all the rows $rand_row = $rows[ array_rand( $rows ) ]; // get a random row $rand_row_image = $rand_row['sub_field_name' ]; // get the sub field value // Note // $first_row_image = 123 (image ID) $image = wp_get_attachment_image_src( $rand_row_image, 'full' ); // url = $image; // width = $image; // height = $image; ?> <img src="<?php echo $image; ?>" />
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've just released ACF 5.12.3 with a security fix to prevent arbitrary file uploads to forms with ACF fields.— Advanced Custom Fields (@wp_acf) July 14, 2022
Now that we've released this update, we recommend updating your sites as soon as possible.
© 2022 Advanced Custom Fields.