Advanced custom field – gallery – display one random image

Shouldn’t you be doing something like this?

<img src="https://wordpress.stackexchange.com/questions/99655/<?php echo $rand["url']; ?>" alt="https://wordpress.stackexchange.com/questions/99655/<?php echo $rand["alt']; ?>" />

Update

I’m not really familiar with that plugin (stuff could be happening behind the scenes) but here’s a better guess than my previous one:

<?php
$gallery = get_field('gallery_home');
$rand = array_rand($gallery, 1);

if( $gallery ): ?>
    <img src="https://wordpress.stackexchange.com/questions/99655/<?php echo $gallery[$rand]["url']; ?>" alt="https://wordpress.stackexchange.com/questions/99655/<?php echo $gallery[$rand]["alt']; ?>" />
<?php endif; ?>

Leave a Comment