Probably the easiest way (at least that I've found so there probably is a much easier way native to WordPress) is to get the Recent Post plugin By Nick Momrik, which allows for the PHP call
[php]<code><?php mdv_recent_posts(); ?>[/php]
in your posts or templates. It also can be expanded to include other paramaters. For example,
[php]<?php mdv_recent_posts(1, '', '<br />', true, 0, true, false); ?>[/php]
The parameters:
- $no_posts (#)- sets the number of recent posts to display
- $before ('HTML Code')- text to be displayed before the link to the recent post (needs single quotes around the text)
- $after (HTML Code')- text to be displayed after the link to the recent post (needs single quotes around the text)
- $hide_pass_post (true/false)- whether or not to display password protected posts
- $skip_posts (#)- allows skipping of a number of posts before showing the number of posts specified with the $no_posts parameter
- $show_excerpts (true/false) - allows the post excerpt to be output after the post title
- $include_pages (true/false)- allows recent pages to be show with recent posts
So,
[php] <?php mdv_recent_posts($no_posts, $before, $after, $hide_pass_post, $skip_posts, $show_excerpts, $include_pages); ?> [/php]
Now, if you wish to use this in one of your blog posts or sidebar widget as I did on one of my sites, you will need another plugin to allow you to use PHP code in your Visual/HTML editor (though the Visual part will have to be disabled) or in your sidebar. Two really good ones are:
- Exec-PHP, requires the visual editor to be turned off (though it can be worked around if you are willing to lose your code if you accidentally switch to the Visual Editor). What would make this a most excellent plugin would be if you could turn off the visual editor only on certain, specific posts and not just everyone.
- Executable PHP Widget, which is like the Text Widget but allows PHP.