Support

Home Forums Add-ons Gallery Field Gallery Code Not Working

Unread

Gallery Code Not Working

  • <?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>
                    <?php echo $image['caption']; ?>
    
                </li>
            <?php endforeach; ?>
        </ul>
    <?php endif; ?>

    I am using the above code in X theme but nothing shows up in my posts. Any ideas as to why?

    This code works:

    <?php 
    
    $image_ids = get_field('gallery', false, false);
    
    $shortcode = '[gallery ids="' . implode(',', $image_ids) . '"]';
    
    echo do_shortcode( $shortcode );
    
    ?>

    but the images are unformatted and not linked to large versions of the images.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.