Home Forums Add-ons Gallery Field Displaying Gallery field for each post entry


Displaying Gallery field for each post entry

  • Hi,

    I am trying to display a gallery using the following code:

    $images = get_sub_field('property_gallery');
    if( $images ): ?>
    <div class="gallery">
            <?php foreach( $images as $image ): 
                $content = '<li>';
                    $content .= '<a class="gallery_image" href="'. $image['url'] .'">';
                         $content .= '<img src="'. $image['sizes']['thumbnail'] .'" alt="'. $image['alt'] .'" />';
                    $content .= '</a>';
                $content .= '</li>';
                if ( function_exists('slb_activate') ){
        $content = slb_activate($content);
    echo $content;?>
            <?php endforeach; ?>
    <?php endif; ?>

    The code works but does not discriminate if the images are from a different post.

    In my test I have 7 images. 4 for one post and 3 for another. When I click an image and opens in lightbox, it says 1 of 7 images.
    How can I make each gallery open only images of a particular post.
    Any help is much appreciated.

  • Hi @javiercastro

    To anyone who may be interested:

    From your other support request, we isolated the cause of this as some buggy code from the Simple lightbox plugin.

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

The topic ‘Displaying Gallery field for each post entry’ is closed to new replies.