Home Forums ACF PRO Gallery array inside a group inside a repeater


Gallery array inside a group inside a repeater

  • Hi all,

    As the title suggests, I have a gallery inside a group, inside a repeater. I currently am successfully getting a text field inside this group, but am stuck getting the images from the gallery that’s inside the group. The gallery is returning in array format. I think $images = get_field($images_group['gallery']); is not exactly right, but I’m not sure.

    What do i need to fix to get the image array fields?

    // repeater
    if( have_rows('manage_your_galleries_test') ):
       while( have_rows('manage_your_galleries_test') ) : the_row();
       // group - using sub_field since group is a repeater field
       $images_group = get_sub_field('images_group');
       if( $images_group ): ?>
          <div id="images_group">
            // returns a group text field
            <h4><?php echo $images_group['gallery_size_text']; ?>
               // get array (?)
               $images = get_field($images_group['gallery']);
               if( $images ): ?>
               <?php foreach( $images as $image ): ?>
                     <a href="<?php echo esc_url($image['url']); ?>">							 
                     <img src="<?php echo esc_url($image['sizes']['thumbnail']); ?>" alt="<?php echo esc_attr($image['alt']); ?>" />								 
                    <p><?php echo esc_html($image['caption']); ?></p>					 
              <?php endforeach; ?>
              <?php endif; ?>
       <?php endif;
    $images = $images_group['gallery'];
  • Thanks John, that helped. Now that I have that working, I have another issue, I will start a new thread here. Thanks for all your help, as usual!

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

You must be logged in to reply to this topic.