selectively show wordpress posts based on category
Posted
by Andy
on Stack Overflow
See other posts from Stack Overflow
or by Andy
Published on 2010-05-03T13:39:00Z
Indexed on
2010/05/03
14:08 UTC
Read the original article
Hit count: 299
Hi, Currently I'm using the following code as part of sidebar code for Wordpress (the code works fine):
<ul class="linklist">
<?php $recentPosts = new WP_Query();
$recentPosts->query('showposts=12');
while ($recentPosts->have_posts()) : $recentPosts->the_post();
?>
<li><a href="<?php the_permalink() ?>" rel="bookmark" title="Link to <?php the_title();
?>">
<?php the_title();
?></a> </li>
<?php endwhile;?> </ul>
It shows the last 12 posts. But what I'm looking for is the following; first check what category the current post (the post that is showing based on the permalink) belongs to, and then only list the latest posts that belong to that same category. What should be edited? Thanks!
© Stack Overflow or respective owner