I created a gallery with the "gallery add-on" of "advanced custom field" plugin.
I'm trying to show one random image from the gallery on page refresh. Here's my code:
<?php $gallery = get_field('gallery_home'); $rand = array_rand($gallery, 1); if( $rand ): ?> <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" /> <?php endif; ?>
But the result is this:
<img src="" alt="">
Where am I missing something?