• Resolved nandorsky

    (@nandorsky)


    Hello,

    How would this work with ACF Gallery fields ?
    https://www.advancedcustomfields.com/resources/gallery/

    <?php 
    
    $images = get_field('gallery');
    
    if( $images ): ?>
        <ul>
            <?php foreach( $images as $image ): ?>
                <li>
                    <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.

    • This topic was modified 6 years, 8 months ago by nandorsky.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Arno Welzel

    (@awelzel)

    It should work. Did you already try it or what is your support question here?

    Thread Starter nandorsky

    (@nandorsky)

    Yes, I did try it and it is not working. I’m wondering if I have to add something to this code for it to work. I tried a WordPress basic gallery and it works fine.

    Thanks for your quick reply.

    • This reply was modified 6 years, 8 months ago by nandorsky.
    Plugin Author Arno Welzel

    (@awelzel)

    I think, the line break my be the problem. Try this:

    <?php 
    
    $images = get_field('gallery');
    
    if( $images ): ?>
        <ul>
            <?php foreach( $images as $image ): ?>
                <li>
                    <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; ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Advanced Custom Fields: Gallery Field’ is closed to new replies.