Support

Account

Home Forums Add-ons Gallery Field ACF Gallery skip first image of gallery field

Solved

ACF Gallery skip first image of gallery field

  • Hi There, i just want to skip the first image of the gallery field. Now all images will show up. Anyone know how to do this?

    This is my actual code.

    <?php $gallery_images = get_field('afbeeldingen_gallerij'); ?>
    
    <?php if( $gallery_images ): ?>
    <?php foreach( $gallery_images as $image ): ?>
    <a href="<?php echo $image['sizes']['lightbox']; ?>" rel="prettyPhoto[<?php global $post; $post_slug=$post->post_name; echo $post_slug; ?>]"></a>
    <?php endforeach; ?>
    <?php endif; ?>	
  • 
    <?php 
      $gallery_images = get_field('afbeeldingen_gallerij');
      $skip = true;
      if( $gallery_images ):
        foreach( $gallery_images as $image ):
          if ($skip) {
            $skip = false;
            continue;
          }
          ?>
            <a href="<?php echo 
                $image['sizes']['lightbox']; ?>" rel="prettyPhoto[<?php 
                global $post; $post_slug=$post->post_name; echo $post_slug; ?>]"></a>
          <?php 
        endforeach;
      endif;
    ?>
    
  • Awesome! thank you for the solution 🙂

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

The topic ‘ACF Gallery skip first image of gallery field’ is closed to new replies.