I hope some of you can help me with this, as it is the last thing i need to complete my project for my last exam.
I am creating a custom wordpress theme, where i am showing all my posts using a foreach loop. Right now, only a div box with a thumbnail picture, the creation date and title are showing for each post, but i want to be able to open a modal box here you can read the post description, when you click a image.
Of course the correct modal box should open according to which post you click.

My code right now looks like this

<div class="news-list">
    <?php $latest_post = get_posts( 'numberposts=4' ); ?>
    <?php foreach( $latest_post as $post ) : setup_postdata( $post ); ?>
          <?php $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' );?>
           <div class="news-post" id="post-<?php the_ID(); ?>">
           <div class="thumbnail-img" style="background-image: url('<?php echo $thumb['0'];?>')">
           <div class="black">
           <?php the_post_thumbnail(); ?>
           <div class="news-headline">
           <small class="time"><?php the_time('j. F Y') ?></small>
           <h3><?php the_title(); ?></h3>
        <?php endforeach; ?>
    <?php wp_reset_query(); ?>

Read more here: How do i create a modal box for each wordpress post in a foreach loop?


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: