<?php$postlist = get_posts('category=6&numberposts=5');
foreach ($postlist as $post) :?><li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li><?php endforeach; ?>
Use this in the sidebar to display a defined number of posts from a specified category. Where it says “category=6” replace the 6 with the relevant category ID number, and where it says “numberposts=5” replace the 5 with the number of posts that you want to appear.
Update Nov. 7, 2007:
The above code snippet can also be used to display a page in the sidebar. This is is handy if you want to create an editable chunk of text in the sidebar without using widgets. So, for example, if you want to show an excerpt of your About page in your sidebar, use the following code:
<?php$postlist = get_posts('id=54');
foreach ($postlist as $post) :?><?php the_excerpt(); ?>
<a href="<?php the_permalink(); ?>">read more</a>
Where it says id=54, replace 54 with the id number of the page you want to display.