Recent Posts
Purpose
This plugin displays a list of the most recent posts to your blog in a highly customisable way.
This is version 2.5.0
. It is compatible with WordPress 1.5–2.5.
- 2.5.0 introduces a new output tag {imagesrc}, and adds more parameters to {image}. Fixes bugs with empty categories, excluded posts, and the option to omit current posts.
- 2.5b25 makes some important changes: the {image} output tag now serves real thumbnails (couple of bug fixes too); output can now be sorted as you choose with sub-headings included; the {date:raw} tag modifier has been added to help the sorting; the ‘trim_before’ option has been replaced with the more logical ‘divider’.
- 2.5b24 fixes to stop recursive replacement by content filter, {gravatar} to allow for ‘identicon’ etc., to {commenter} to allow trimming, and to remove a warning in safe mode
- 2.5b23 brings a new option to filter on custom fields and adds proper nesting of braces in {if}.
- 2.5b22 fixes bugs in several output tags, and introduces the option to show only pages.
- 2.5b18 fixes filtering output and introduces the conditional tag, (if:condition:yes:no}.
- 2.5b16 fixes a problem with {php}.
- 2.5b15 more bug fixes and added ‘included posts’ setting.
- 2.5b14 continuing bug fixes.
- 2.5b11 has new features and improvements.
- 2.3.6 restores the widgetiness I managed to remove in 2.3.5!
- 2.3.5 has been rebuilt to save memory and can match the current post’s tags. It also fixes a bug with categories in WordPress < 2.3.
- 2.3.4 now works as a widget. Also can include or exclude the current post from the output.
- 2.3.3 beta adds the ability to include as well as exclude categories and authors and is able to find posts by tag.
- 2.3.2 beta fixes a conflict between tags and categories.
The plugin has an options page which lets you change how the output is generated and displayed.
Installation Instructions
- If upgrading from a previous version, first deactivate the plugin via the Plugins page and delete the plugin folder from your server.
- Upload the plugin folder to your /wp-content/plugins/ directory. You will also need to install the Post-Plugin Library.
- Go to your admin Plugins page and activate Recent Posts.
- Put
<?php recent_posts(); ?>at the place in your theme files where you want the list of similar posts to appear. Lorelle on WordPress has a good guide to modifying themes for plugins. If you are using a widget-ready theme the plugin can be placed from the widget admin page. - Use the admin Settings|Recent Posts page to set all the available options. Alternatively, the options can be overridden by passing a parameter to the recent_posts template tag.
Usage and Options
The configuration page will help you to set up the plugin to your satisfaction.
If you also install the latest version of Plugin Output Cache the output of this plugin will be automatically cached for efficiency.
Note: If you find that your list of recent posts comes out backwards it is probably because you have MySQL version 4.1.21. That version of MySQL has a bug when a SELECT statement has both DISTINCT and ORDER BY clauses. The latest versions of the plugin (2.5+) avoid this MySQL bug.
Finally…
I look forward to your help in ironing out any issues and implementing any good ideas. The plugin settings page has an option to submit bug reports but general comments can be left below.
Frequently Asked Questions
-
Is it possible to show the recent posts per category? Something like:
CATEGORY:
*recent post 1
*recent post 2
* and so on…
CATEGORY 2:
*recent post 1
*recent post 2
* and so on…Yes it is possible but only by calling Recent Posts a number of times which is inefficient (though caching helps). Try:
recent_posts('included_cats=1'); recent_posts('included_cats=2'); ... -
I would like to know if there is any way to display the recent posts in 2-3 columns?
One way is by fancy CSS/JavaScript… but you can get the result by calling recent_posts() 2-3 times. Let’s say you want 5 posts in each column so you set the limit to 5 in the settings screen. The first time, recent_posts() gets you the top 5 posts; recent_posts(’skip=5′) the next 5; and recent_posts(’skip=10′) the next.
-
How do I get it so that {link} displays the date instead of the title? If i use the {date} template tag, it shows the date but no link.
You need to use the output template to tell the plugin exactly what to display. For example, if you want a link where the visible text shows the date of posting you could try:
<li><a href="{url}">{date}</a></li> -
How do I format the output of the {date} tag?
The blog’s date format is used by default but you can change it by adding a format string. The Codex has a page on format strings. Let’s say you want the date to look like Sunday, January 14, 2007. The correct format string is ‘l, F j, Y’ so you would write
{date:l, F j, Y} -
I don’t want my post plugin widget to show on the main page, just the single post page. Is that possible?
Yes. The widgets now let you choose the condition under which they are visible. The condition can be set using any combination of WordPress Conditional Tags, e.g., ‘is_home()’, ‘is_category()’, or ‘is_page()’.
In this case the right condition is ‘is_single()’.
-
I’m trying to place the plugin output just after a single post but other plugins seem to get in there first. Any ideas?
Some plugins automatically tack on their output to the end of a post’s content. The only way to get something in between is to hope that those plugins offer a way to turn off that kind of behaviour and let you explicitly place their output with a template tag. The good news is that most plugins are cooperative.
-
I found a script that allows me to put thumbnail images [or anything else] with each post. I was wondering if there was a way to integrate that with this plugin?
If the script stores the thumbnails in a custom field you can use the output template tag {custom} to display them. Try
something like:<img src="{custom:thumbnail}" alt="{custom:thumbnail-alt}" />A similar thing can be done with many other plugins.
-
I want to show the same plugin in two different places but with different output: can I?
Yes. Decide on one of the output templates and other settings you need and set them up from the options pages. The other invocation of the plugin then gets called with passed parameters to get the different output.
e.g.,random_posts('limit=3&output_template={custom:another_field}') -
I want an output template tag to do xxxxxx. How do I invent one?
You have two choices: a) modify the output_tags.php in the post-plugin-library; b) use the {php} tag.
If you go down route (a) (which is actually very easy) please let me know the new tag and I’ll maybe include it in the next version. If you use the {php} tag do be careful not to start WWIII. -
I uninstalled one of your plugins and now my whole sidebar has disappeared. How do I get it back?
You have probably forgotten to remove the code calling the plugin, e.g., recent_posts();.
I find a good practice is to use something like:if (function_exists('recent_posts')) { recent_posts(); }That way, if I ever deactivate a plugin temporarily the website doesn’t fall apart.
59 Comments Add your own
1. Rob | March 17th, 2008 at 6:20 pm
2. Sue | March 25th, 2008 at 2:12 am
Hi Rob,
I got this running right away, and would like to do just one thing, and that is indent the date by 2 spaces or align it with the link. How do I do that?
Thanks!
Sue
3. Rob | March 25th, 2008 at 8:12 am
4. Sue | March 26th, 2008 at 4:48 am
Hi Rob,
I am using this in my right sidebar in the area near the top entitled “Featured”. I have jury-rigged the date by using to push it to the right 2 spaces but would like to affect that indentation using proper code with your plugin. Would I use a div code for that? I am using your date code in the plug in config with the post link.
many thanks,
Sue
5. Rob | March 26th, 2008 at 7:51 am
<ul>in the Featured section. You are probably placing one before the plugin call AND asking for one in the plugin output (the prefix setting). Get rid of one or the other and the output should behave like your other lists… if that is what you want!6. thomas | April 3rd, 2008 at 8:05 pm
Updated my blog to WP 2.5 and after updating the Recent Posts plugin it only shows the message “Post-Plugin Library missing”.
How can I fix this?
7. thomas | April 3rd, 2008 at 8:06 pm
Ah, sorry. Found out I have to install the post-plugin library plugin. I am really sorry.
8. printer | April 4th, 2008 at 5:08 pm
Thanks for this great plugin. Its pefect for the site I am building.
I have a question though, I have this other plugin called “Post Thumb Revisited”. i want to put the thumbnails generated by this plugin to show up before my recent-posts titles in the sidebarwidget. I’m not sure what it is that I should put in the ‘ custum field’ .. i think it should be something like this:
<li>{link}<img src="{custom:function get_thumb}"</li>but what can be the so called ‘custom field’? ‘function get_thumb’ does not work. an url to the folder does not work either. Any hints on this? Thanks!9. Rob | April 4th, 2008 at 6:02 pm
10. online business blogger | April 5th, 2008 at 2:23 am
Rob
can this plugin RecentPost work with wordpress static pages? I have it working with posts but, of course, pages don’t have categories.
forgive me for taking up your time with silly questions, guess I should RTFM
11. Rob | April 5th, 2008 at 3:24 pm
12. printer | April 7th, 2008 at 9:10 pm
Thanks Rob, i tried what you said.. Both ways worked indeed. I like the php field option. to bad i can not get it to display the thumbnail fot the correct post.. only the first one. i will try some more.. thanks for the hint.
13. Rob | April 7th, 2008 at 9:17 pm
$resultvariable — an object corresponding to each post with values named after the columns of $wpdb->posts. For example, $result->ID.14. printer | April 8th, 2008 at 12:11 am
Rob, I understand what you mean. I think.. The get_thumb() tag needs a reference to the post. What I now have is
{link} {php:get_thumb()}in my field input. It has to be somthing like{php:$wpdb->posts->$result->get_thumb()}then? I will try some tommorow. thanks15. Rob | April 8th, 2008 at 12:36 am
16. adspedia | April 8th, 2008 at 9:39 am
Is it possible to show a area of recent blog posts to my website, thus outside the WP CMS?
17. Rob | April 8th, 2008 at 9:49 am
18. Printer | April 8th, 2008 at 12:16 pm
Rob, I understand. I tried it with the {image} tag. Unfortunately it looks like the image get scaled (when I set the settings to display the image smaller). And therefore it looks a little “pixelated” or whatever, instead of creating a real thumbnail of course. But I think I will leave it without an image-thumb in the recent-posts then. I found the ‘Post Thumb Revisited’ plugin a little hard to tweak and manage to my liking. So I will stay with the recent-posts plugin for now. Thanks.
19. Rob | April 8th, 2008 at 12:39 pm
20. Printer | April 8th, 2008 at 6:58 pm
That would be great Rob. I’m building an illustration blog where different authers will publish there work. A thumbnail would be a nice little extra within the recentposts list. I’m realy looking foreword to it.Thanks very mutch for all the help so far! Ill stay tuned.
21. Rene | April 8th, 2008 at 10:27 pm
Hi Rob,
first of all: I like you’re plugin very much! And your ‘how to’ is very clear.
One question: I’m using the {image} tag in the recent comments. The images show up indeed, but I want some extra space between the image and the text. Is that possible? And, if yes, how? Thanks for your attention in advance.
22. Rene | April 8th, 2008 at 10:39 pm
Oh… I’m sorry. I found the solution right after I posted my question. Quite simple after all. I just added
#recent-posts img {
margin: 0 5px 0 0;
}
to my stylesheet.
23. Rob | April 8th, 2008 at 10:43 pm
24. Kuri | April 10th, 2008 at 10:21 am
Thanks for this plugin. However, upon installation, it seems the plugin isn’t picking up on the CSS for links styling? Any advice on what I should do here?
25. Rob | April 10th, 2008 at 2:02 pm
26. Diwaker | April 10th, 2008 at 6:26 pm
I recently upgraded the plugins (using the Wordpress auto upgrade mechanism). Everytime I upgrade your plugins (shared library, similar/recent posts, recent comments etc), I lose the corresponding widgets from my theme and I have to go back and re-enable them. Is this a known issue? Thanks for the great work!
27. Rob | April 10th, 2008 at 9:22 pm
28. Jens | April 13th, 2008 at 11:19 am
Hey!
I have used your recent posts plugin for a while now and it has been working great! Today I used the wordpress upgrade plugin automatically-function to get the latest version, after this it also said i needed the post-plugin library, which i didn’t have before, and i installed it. The problem is, now it doesn work anymore, and i had to remove it from my first page where i used to have my recent posts listed.
The problem was that when it came to fetch the posts, it just stopped and nothing showed, and also the loading of the rest of the page stopped. Do you know what the problem might be? Thanks! // Jens.
29. Rob | April 13th, 2008 at 11:27 am
30. Jens | April 13th, 2008 at 11:44 am
Hey, thanks for the quick reply! Unfortunately it doesn’t seem to work. It is in place, I tried to deactivate and activate again, but as you see on my first page, http://www.jensfilipsson.com, it doesn’t load up correctly. If you check http://www.jensfilipsson.com/blogg, i also have a footer that doesn’t load up on the first page. And of course, no recent posts there either.
31. Rob | April 13th, 2008 at 12:24 pm
32. Jens | April 13th, 2008 at 12:27 pm
Done!
33. Jens | April 13th, 2008 at 1:03 pm
Hey, I just went to look at my widgets page, and instead of displaying the list of availible widgets and sidebars, it stops loading at the recent posts widgets, which looks like thiis:
%BEG_OF_TITLE%Recent Posts%END_OF_TITLE%
so I guess there’s something wrong with the code or something somewhere?
34. Rob | April 13th, 2008 at 2:22 pm
Meanwhile I’ll look again at the Recent Posts code.
35. Jens | April 13th, 2008 at 2:37 pm
Hey!
Unfortunately I have options set, they are the same as before I upgraded. And, the problem with the widget not loading correctly I would say suggests that something is wrong.
I’m removing it from my front page now, so that the page can load normally, but I hope to be able to put it back soon, it’s a great plugin! :)
36. Rob | April 13th, 2008 at 5:21 pm
37. Ghost | April 16th, 2008 at 12:56 pm
Hi there Rob,
I don’t know how to use this plugin exactly. I’ve installed everything necesary and i’ve installed the Recent_posts plugin but i dont know how tu put it on the first page . I want to use this plugin to show the latest posts in one single post . For example , let’s say i’ve posted 5 posts recently . I want to show a list with the latest posts in one single post on the front page of my website I hope you understand what I want .
38. Rob | April 16th, 2008 at 3:14 pm
You have to insert a call to recent_posts() somewhere in your one of themes’ php files. But where depends on the answer to the questions I asked?
Give me a clue and I’ll be glad to help.
39. Ghost | April 16th, 2008 at 6:43 pm
I think it’s more a static page . I want to have a list of the lastest 30 posts for example on the main page , in the center , like a post . I don’t want the Latest_posts plugin on the right or left , just in the center of my main page .
40. Rob | April 17th, 2008 at 4:55 pm
For more information visit the codex: here, here, or here
Good luck!
41. Martin | April 18th, 2008 at 12:58 am
Hi
Fantastic plugin, lots of features. Well done !
Quick question , I want to put the {categorylinks} at thetop of the links but it keeps repeating the {categorylinks} for each post link…. how can I get around this ?
{categorylinks}
{date: F j} | {link}
This keeps repeating the category link above each category post. I just want one instance of the category link at the top.
thanks
Martin
42. Rob | April 18th, 2008 at 9:35 am
43. Martin | April 18th, 2008 at 9:56 am
Hi Rob
Thanks for that. Ok , so what is the code syntax to put the category link before the call to recent_posts(). I had a look on the site here but coudnt find any examples.
Thanks
Martin
44. Rob | April 18th, 2008 at 10:00 am
<?php the_category(','); ?>.45. Martin | April 18th, 2008 at 10:47 am
OK thanks Rob. That *worked* but I am using two instances of the recent posts on the same page and because its showing posts from two seperate categories, then it will only show the first category title on that page ….. unless I am missing something .
thanks again
Martin
46. Rob | April 19th, 2008 at 10:08 am
get_category_link()to get the category url which you would have to wrap in a hyperlink.If you look at the ‘otf_categorylinks’ function in ‘/post-plugin-lubrary/output_tags.php’ it will give you the idea.
47. Arwen | April 19th, 2008 at 2:28 pm
Hi Rob. Firstly I want to let you know that I really love your plug-in. I have a simple question, and the answer is probably right in front of my face, but I can’t for the life of me figure it out.
I am building a theme for my site that uses the Recent Posts plugin to show a list of “updates” posts on my sidebar. All of these one-sentence posts will go in the “update” category in my WP. Now I’ve easily and quickly configured your plug-in so that it only shows the posts from the “update” category, but now how do I exclude those very same posts from my WP main page?
Essentially, I don’t want them showing up as normal posts on my blog, I want them showing up on the “updates” section of the sidebar. I’m halfway there, I just need to figure out how to exclude them from showing up on the front of my blog when I post a new one.
For example:
The “snippets” on http://www.guitarangel.net
or
The “asides” on http://www.jemjabella.co.uk
48. Rob | April 19th, 2008 at 4:06 pm
Here are a couple of resources that should help. These, from the Codex and Perishable Press, seems right on the mark. The other, from the Codex, is more general.
I hope these help!
49. Arwen | April 19th, 2008 at 4:37 pm
Thank you very much!
50. Arwen | April 19th, 2008 at 4:48 pm
Thanks… although they don’t really help with the new version of wordpress. They make references to category ID numbers, which I can’t find in the new wordpress admin panel.
51. Rob | April 19th, 2008 at 5:24 pm
Good Luck!
52. Arwen | April 19th, 2008 at 5:25 pm
Nevermind, I was able to figure it out. Thank you for the help!
53. Blog Bloke | April 25th, 2008 at 8:33 am
When I try to deactivate the plugin it blows apart my template right after section that I used your plugin. Any suggestions?
…BB
54. Lucas | May 13th, 2008 at 11:11 am
I think its a great plugin, too bad it doesn’t have a feature to hide it from the frontpage, so its only visible when a single article is viewed! I do like the option that you can skip a number of posts!
55. Lucas | May 13th, 2008 at 11:13 am
Sorry, I found it!! Great plugin!
56. Lucas | May 13th, 2008 at 11:52 am
I would like to show Recent Posts on pages and single posts.
So I use the option, is_single() on the widget page where it says ’show only if page’. Now the recent articles are not showed on pages.
In the General Settings page there is an options ‘Show static pages?’. Setting this to ‘Both pages and posts?’ also shows pages on the recent posts list. And shoulds it only on single posts!
In the widget page (’show only if page’.) I changed is_single() to is_single(),is_page() and is_single(),is_page(pagename) and to is_single();is_page() with a dot/comma. But the recent posts list is showed on the pages like this.
How can this be done?
Great help!
57. Lucas | May 13th, 2008 at 11:54 am
In the widget page (’show only if page’.) I changed is_single() to is_single(),is_page() and is_single(),is_page(pagename) and to is_single();is_page() with a dot/comma. But the recent posts list is NOT showed on pages like this.
How can this be done?
58. Rob | May 13th, 2008 at 2:28 pm
is_single() || is_page()i.e., show if a single ‘page’ OR (’||’) a page ‘page’.
59. Lucas | May 13th, 2008 at 11:26 pm
Thanks, you are my person of the day!
Leave a Comment
Trackback this post | Subscribe to the comments via RSS Feed