Support

Account

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

Helping

how view tow gallery together and field gallery name

  • hello
    How to View Two Gallery Together?
    and how to view field gallery name in gallery = <h6>by section:<?php echo $image['XXXX']; ?></h6>

    the code gallery

    <?php 
    
     $mygallery01 =  get_field('mygallery01');
     $mygallery02 =  get_field('mygallery02');
    
    $images =XXXXXXX;
    
    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 endif; ?>

    thanks..

  • 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 }
        }        
    }
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.