Home Forums ACF PRO Display Gallery Images Excluding First?


Display Gallery Images Excluding First?

    • jez

    • June 27, 2016 at 8:39 pm

    Is it possible to display a list of gallery images excluding the first one of the group?

  • This code is taken from with a little addition to skip the first image. I added a counter and check it to see if it’s the first one.

    $images = get_field('gallery');
    if( count($images) > 1 ): 
    $count = 0;
            <?php foreach( $images as $image ): 
    if ($count == 0) {
      // skip the first one
                    <a href="<?php echo $image['url']; ?>">
                         <img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['alt']; ?>" />
                    <p><?php echo $image['caption']; ?></p>
            <?php endforeach; ?>
    <?php endif; ?>
    • jez

    • June 28, 2016 at 12:33 am

    Brilliant thank you John.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.