Support

Account

Home Forums Add-ons Gallery Field Can I add a class to first image in gallery loop Reply To: Can I add a class to first image in gallery loop

  • Thanks for this John, I worked this in nicely to an image slider using the Gallery field:

    <div class="page-block-right slide-nav-section">
              <?php 
    $images = get_field('gallery');
    $size = 'large'; 
    if( $images ): ?>
            <?php foreach( $images as $image_id ): ?>
              <input type="radio" id="<?php echo $image_id;?>" name="slider" <?php 
           if ($count == 0) {
             echo 'checked';
           }
            ?> >
               <label for="<?php echo $image_id;?>"></label>
    <div class="slide bg4"><?php echo wp_get_attachment_image( $image_id, $size ); ?></div>
                   <?php $count++; ?>
            <?php endforeach; ?>
    <?php endif; ?>         
          </div>