I have a series of image posts displayed on a page of a WP site that uses Bootstrap 4
The images normally display in a larger size when they're clicked on but I want to display them in a dropdown modal _ The problem is that when I implement the modal it only displays the last post on the page NOT the image that was clicked on _
I realise this is because I need to get the post ID and add the same ID to the modal code _ However, I have tried several ways of doing this but not been successful
this is the code I currently have on the page >>>
<?php get_header(); ?>
<div class="container fadeIn" id="perimeter">
<section class="gallery" id="mainGallery">
<div class="container">
<div class="row">
<?php $featured_query = new WP_Query( array(
'category_name' => 'canvas'
)); ?>
<?php while($featured_query->have_posts()) :
$featured_query->the_post(); ?>
<div class="col-md-6">
<div class="divPad">
<a data-toggle="modal" data-target="#galleryModal" href="<?php echo the_permalink(); ?>">
<?php the_post_thumbnail(); ?>
<?php $post_id = get_the_ID(); ?>
</a>
<br />
<span class="fontBrand1 fontType1 text"><?php echo the_title(); ?></span>
<span class="fontBrand2 fontOpenSans smallText"><?php echo get_post_meta($post->ID, 'Materials', true); ?><?php echo get_post_meta($post->ID, 'Dimensions', true); ?><?php echo get_post_meta($post->ID, 'Price', true); ?></span>
</div><!-- /.divPad -->
</div>
<?php endwhile; ?>
</div><!-- /.row -->
</div><!-- /.container -->
</section><!-- /#mainGallery -->
<div class="horizBuffer2"></div>
</div><!-- /#perimeter -->
<!-- modal -->
<div class="modal fade" id="galleryModal" tabindex="-1" role="dialog" aria-labelledby="galleryModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="galleryModalLabel">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<?php the_post_thumbnail(); ?>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div><!-- /.modal-content -->
</div>
</div><!-- /#galleryModal -->
<?php get_footer(); ?>
Any help would be greatly appreciated _ thanks