Support

Account

Home Forums ACF PRO Show First image of gallery Reply To: Show First image of gallery

  • I don’t understand sorry. I get gallery with the next code. How can modify for get/show only first image of gallery? Really thanks!

    <?php 
    
    $images = get_field('images');
    
    if( $images ): ?>
        <ul class="imagegallery">
            <?php foreach( $images as $image ): ?>
                <li>
                    <a href="<?php echo $image['url']; ?>" rel="lightbox">
                         <img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['alt']; ?>" />
                    </a>
                    <?php echo $image['caption']; ?>
    
                </li>
            <?php endforeach; ?>
        </ul>
    <?php endif; ?>