Home › Forums › Add-ons › Repeater Field › Random repeater › Reply To: Random repeater
Hi @jmeiii
Here is a snippet of code for you to use.
It will load the repeater field, then shuffle the rows and then loop through the rows and render the HTML.
Please note you can’t use any of the sub field functions with this code:
<?php
$rows = get_field('career_grid');
if($rows)
{
shuffle( $rows )
foreach($rows as $row)
{
$image = wp_get_attachment_image_src( $row['image'], 'full' );
?>
<a href="<?php echo $row['link']; ?>">
<img src="<?php echo $image[0]; ?>" alt="<?php echo $image['alt']; ?>" />
</a>
<?php
}
}
?>
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.