I am attempting to create a listing of Blog Posts by Date(Month) and show the featured image for each.
<div id="datePostTime"><h2>Posts for <?php echo get_the_date('F, Y'); ?></h2></div>
<?php // The loop ?>
<?php if ( have_posts() ) {
while ( have_posts() ) {
if ( has_post_thumbnail() ) {
echo "<div id='post_thumbnail'>";
the_post_thumbnail();
echo '<h4>' . get_post(get_post_thumbnail_id())->post_excerpt . '</h4>';
echo "</div>";
}
the_post();
the_content();
echo "<br />";
echo "<div id='the_post_date'>";
the_date('','Article posted on ', '.');
echo "</div>";
echo "<br />";
} // end while
} // end if ?>
My code above is showing each individual blog post. However, the very first thumbnail image is then posted for each blog post. So regardless of what thumbnail I pick for the post, all of them show the same image as the first one loaded.
So it looks like this -
> Image 1
> My Post
> Post date
> Image 1 again
> My next post
> next post date
Why am I having repeating thumbnail images?