Support

Account

Home Forums Add-ons Gallery Field Target gallery inside group

Solved

Target gallery inside group

  • Hi everybody,

    I have a gallery living inside a group field and don’t know how to target it.
    Right now the images are not showing and since all else is fine I guess…

    <?php
    $studio = get_field('studio');	
    if( $studio ): ?>
    ...
    <?php 
    $images = get_field('gallery');
    $size = 'medium';
    if( $images ): ?>
    <ul>
    <?php foreach( $images as $image ): ?>
    <li>
    <?php echo wp_get_attachment_image( $image['id'], $size ); ?></li>
    <?php endforeach; ?>
    <?php endif; ?>
    ...
    <?php endif; ?>
    

    Thanks in advance

  • https://www.advancedcustomfields.com/resources/group/

    
    $images = get_field('{GROUP_FIELD_NAME}_gallery');
    
    
    $group = get_field('{GROUP_FIELD_NAME}');
    $images = $group['gallery'];
    
    
    if (have_rows('{GROUP_FIELD_NAME}')) {
      while (have_rows('{GROUP_FIELD_NAME}')) {
        $images = get_sub_field('gallery');
      }
    }
    
  • Thanks for the hint, John.

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

You must be logged in to reply to this topic.