I created a separate page for blog posts on my website (WordPress). I Used this code for showing 6 last posts:
<div class="container">
<div class="entry-content">
<div class="last-posts">
<?php $the_query = new WP_Query( 'posts_per_page=6' ); ?>
<?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
<div class="col-md-4">
<div class="post-item">
<a href="<?php the_permalink() ?>" target="_blank">
<figure><?php the_post_thumbnail(); ?></figure>
</a>
<div class="post-detail">
<h3>
<a href="<?php the_permalink() ?>" target="_blank">
<span><?php the_title(); ?></span>
</a>
</h3>
</div>
</div>
</div>
<?php
endwhile;
wp_reset_postdata();
?>
</div>
</div>
</div>
The problem is, this loop works from "container" class to the end of the code, not just 6 last posts. This loads all 6 posts 6 times.
</div>