I am writing a code to display the recent posts of different categories. On clicking category 1, I want to display the recent posts from cat1 and on clicking cat 2 the recent posts from cat2 and so on.
The code I have written was displaying the same posts on all cats.
What should I do?
<?php
$rPosts = new WP_Query();
$rPosts->query('showposts=4&category_name=category1');
while ($rPosts->have_posts()) : $rPosts->the_post(); ?>
<h4><a href="#">POSTS FROM THIS CAT</a></h4>
<p><?php the_post_thumbnail(array(300,221)); ?> </p>
<h3><a href="#"><?php echo get_the_title();?></a></h3>
<p><a class="btn btn-white" href="<?php the_permalink(); ?>">Read Full Story</a></p>
<?php
endwhile;
?>