Listing posts from one category
Sometime it is needed to display list of all post from only one category in some specified place on your site eg. a sidebar.
To achieve that you need to put following code in the place you want to have that list:
<ul>
<?php
global $post;
$myposts = get_posts(’numberposts=10&order=DESC&orderby=post_date&category=xx’);
foreach($myposts as $post) :
setup_postdata($post);
?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> </li>
<?php endforeach; ?>
</ul>
xx need to be replaced with ID of that particular category.
If you want to display also content of those posts just add this
--- <?php the_content(); ?>
between </a> and </li> . And done ;).
14th October 2007 no comments yet




