Support

Account

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
    	}
     
    	
    }
    
    ?>