I have ACF repeater and showing one field on each page load using array_rand(), but I need the fields to be shown one by one in the order (row 1, row2, row 3), so randomness but by order. This is what I have now, and can't get how to make this order.
if ( get_field('random_non-random') == 'random' ) {
echo '<div class="all-featured-image landing">';
$rows = get_field('random_featured_image' );
$rand_row = $rows[ array_rand( $rows, 1 ) ];
$rand_row_image = $rand_row['featured_image'];
$image = wp_get_attachment_image_url( $rand_row_image, 'full' );
echo '<img src=" ' . $rand_row_image['url'] .' " alt="' . $rand_row_image['alt'] .'" title="' . $rand_row_image['title'] .'">' ;
echo '</div>';
}
Seems like I need to use count($rows) somewhere?
Aucun commentaire:
Enregistrer un commentaire