Display featured image URL in the loop

I have a problem trying to get the thumbnail URL of each post on the archive page.
I used the basic technics but it always return the url of the first featured image of the page.

Here the part of the code of my template-parts/post/content/content.php

The goal of this is to open the featured image of each post on a lightbox.
Here the link to the page : http://leos-sipek.thomasdesnoyers.com/category/divers-types-dune-ideographie-stochastique/peinture-sur-papier/metaplasme/

If you click on the second post it shows the featured image of the first post.

    <div class="post-thumbnail">
        <a rel="lightbox" data-gall="gall-frame" data-lightbox-type="inline" href="#inline-content">
            <?php the_post_thumbnail( 'twentyseventeen-featured-image' ); ?>
        </a>
    </div>

    <!-- Lightbox -->

    <div id="inline-content" style="display:none;">
            <?php if (has_post_thumbnail( $post->ID )) : ?>
            <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
            <div class="img-single" style="background-image: url('<?php echo $image[0]; ?>')"></div>
    </div>

Thanks

Read more here: Display featured image URL in the loop

Leave a Reply

Your email address will not be published. Required fields are marked *