Support

Account

Home Forums ACF PRO how view tow gallery together and field gallery name Reply To: how view tow gallery together and field gallery name

  • You should loop through $mygallery01 and $mygallery02 not through $images.

    $images is an incorrect defined string.

    I think this will do the trick.

    $galleries = array( 'mygallery01', 'mygallery02' );
    
    if ( $galleries ) { 
        foreach( $galleries as $gallery ) { 
            $images = get_field($gallery);
            if ( $images ) {
            ?>
            <ul>
                <?php foreach( $images as $image ): ?>
                    <li>
                        <h6>by section:<?php echo $image['XXXX']; ?></h6>  
                        <a href="<?php echo $image['url']; ?>">
                             <img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['alt']; ?>" />
                        </a>
                        <p><?php echo $image['caption']; ?></p>
                    </li>
                <?php endforeach; ?>
            </ul>
            <?php }
        }        
    }