Support

Account

Home Forums Add-ons Gallery Field Random image from Gallery field Reply To: Random image from Gallery field

  • I think I’ve got it!

    
    <?php 
    	
    $images = get_field('header_image', 'option');
    $rand = array_rand($images, 1);
    	
    if( $images ): ?>
    	<div>
    		<img src="<?php echo $images[$rand]['url']; ?>" alt="<?php echo $images[$rand]['alt']; ?>" />
    	</div>
    <?php endif; ?>