Recent Posts

Caveat

Unfortunately, due to ill-health, this plugin has not been developed or supported properly for some years. It works with the latest versions of WordPress (including on this website) but could possibly conflict with any WordPress features added after 2008 — e.g. custom post types — if you use them.

Purpose

This plugin displays a list of the most recent posts to your blog in a highly customisable way.

This is version 2.6.2.0 download latest version. It is compatible with WordPress 1.5–2.6.2.

  • 2.6.2.0 supplies a .pot file making internationalisation possible; introduces the {imagealt} output tag and allows {excerpt} to output whole sentences; the content filter and the widget can now take a parameter string; output can be automatically placed after post content without editing theme files.
  • 2.6.1.0 allows the current post to be marked manually where the automatic mechanism fails; when used as a widget the plugin now honours the setting to show nothing when there is no output; and {commenterlink} now applies the appropriate WordPress filter.
  • 2.6.0.1 fixes the option to include attachments and adds a parameter to the {imagesrc} output tag to append a suffix to the image name.
  • 2.5.0.11 has a new option to include posts which are attachments; a new output template tag {authorurl} which points to the archive of the author’s posts; new behaviour for the {php} output tag which can now accept other output tags in the code.
  • 2.5.0.10 fixes several bugs.
  • 2.5.0.9 adds options to match the current post’s author and to select posts by date of last modification rather than date of creation. Also extends the options for snippet and excerpt output tags to make the ‘more’ text into a link.
  • 2.5.0.8 adds an option to show posts by status, i.e., published/private/draft/future, changes the {categorynames} and {categorylinks} output tags by applying the ‘single_cat_name’ filter, and fixes a bug in WordPress pre-2.2 that stopped installation code running on Windows servers.
  • 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

  1. If upgrading from a previous version, first deactivate the plugin via the Plugins page and delete the plugin folder from your server.
  2. Upload the plugin folder to your /wp-content/plugins/ directory. You will also need to install the Post-Plugin Library.
  3. Go to your admin Plugins page and activate Recent Posts.
  4. 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.
  5. 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.

238 replies on “Recent Posts”

  1. Hi,

    How can I call the plugin in the php file. I mean I have a sidebar2 php file which I will use only in the single page and in the Author’s page. So, how can I call the plugin to appear only in these pages. The reason is that in the front page I have sidebar with loads of things and I dont want them to appear in the single page or in the auhor’s page. For this, I need to call the plugin in the sidebar2.php file I have created. How can I do this?

    Plz help me.

  2. Rashed: You just insert the following code at the place in the sidebar2.php file where you want the list to appear:

    
    if (function_exists('recent_posts')) recent_posts();
    

  3. Thanks mate for replying.

    I\’m not sure is it going to show the posts by that author only or it is going to show recent posts from any author.

    Thanks again for the prompt reply. πŸ™‚

    I love your plugins. πŸ˜€

  4. Wow!!! This is what I’ve been seeking for so desperately.
    Thank you sooooo much for this amazing plugin πŸ™‚

  5. I think the UTF8 conversion doesn’t work with “recent post”. All the accent get wrong for the posts displayed by this plugin. The accents are right with random posts or when I display the index page.
    You can see an example on my site. The firts posts on the welcome page are displayed by recent posts. The 5 next ones by random posts. If you click on “La suite…” you can go on the index page and the accent come back.

    Thanks in advance!
    V 2.6.2.0 for the plugins, V 2.6.2.1 for the library.

  6. Artwo: Can you tell me the output template you are using for each plugin?

    I am puzzled because the two plugins share the same code for generating output so it isn’t clear why they are behaving differently. Maybe the details will help.

  7. my output template:

    <div class="post" id="post-{postid}">
    <h2 class="storytitle border1">{link}</h2>
    <div class="meta">
    {php: if(function_exists('the_ratings')) the_ratings(); if (function_exists('get_cat_icon')) get_cat_icon('small=true&fit_width=24&fit_height=16&max_icons=2&use_priority=true&cat='.list_icons({postid})); }{categorynames:,}
        </div>
    	<div class="storycontent">{fullpost}</div>
    <div class="feedback">
    {php: comments_popup_link(__('No Comments'), __('1 Comment'), __('% Comments'));}</div>
    	</div>

    I’m using the same for the random posts

    Thanks

  8. Artwo: Very mysterious! Both plugins call the same function to fill in the {fullpost} output template tag.

    One difference I note is that Recent Posts uses my Plugin Outoput Cache which Random Posts does not. I have just uploaded a new version of the cache plugin (4.0.7) which I hope will fix the problem. Make sure you un-install the old version before installing the new.

  9. Hey Rob,

    Can you add an option to filter posts so that a post by an author does not appear twice in a list of say 10 posts ? So it would be like recent posts but only one per author.

    Thanks πŸ™‚

  10. Hi
    I have RecentPosts running nicely on our front page (even 3 instances), but I wonder: Is it possible to have another instance of it showing the most recent post (with image) from an other WP installation?
    (For practical reasons different departments of our site runs on separate WP installations – and I’d like the latest post from “dep 2” on our front page.)
    Thanks,
    Kjetil

  11. Can you please Help?
    What I’m doing wrong?
    I am using WP 2.6.3 Thank you so much!!!

    Fatal error: Call to undefined function: recent_posts() in /homepages/35/d34000493/htdocs/blog_uepsilon/wp-content/themes/simple_business/second.php on line 11

  12. Hi

    I have a single page – which I want to use as an index page with excerpts of several recent posts …. followed by the list of links to posts in category order. On any posts page I want to have a recent posts widget just showing links to the most recent posts.

    I was originally using the recent posts widget that comes as default with wordpress. And had set this up exactly as required for the posts.

    I then set up your recent posts plugin so that I could have some excerpts on my main page. However your recent posts plugin supercedes the default one Ive got as a widget and hence it doesnt seem to be possible to have the recent posts excerpts on Page 1 and just the links (not excerpts or any other of the formatting) in the widget.

    Is thre any way around this?

    Was there any reason for having your plugins widget the same name as the default one? As its not possible to have both in use – yours on page1 and default widget on my posts.

    many thanks

    Martin

  13. A couple of issues.

    First, is there any way to set Recent Posts so it displays the posts that the viewer currently sees onscreen? For example, if I’m viewing Page 2 of my blog, displaying posts 6-10, Recent Posts would show those headlines.

    If this isn’t possible, I’d like to at least be able to set Recent Posts in my single.php template so it displays the headline for that entry.

    Recent Comments offers the just_current_post parameter, but this is not available for Recent Posts.

    Second, when I hover over the link created by {link}, it only displays the date — not the title of the post, as it’s supposed to.

    Any reason why this occurs?

    Thanks.

  14. I can’t even begin to describe how happy this plugin has made me. I spent 2 days just solidly looking through tutorials, asking for help from snarky wordpress moderators, trying other plugins. I can’t believe I didn’t find this earlier. I almost feel like crying, I think you’re my favourite person right now. It does exactly what I want it to and the plugin is built so extensively I can’t even begin to imagine the time and effort you’ve put into this – just to give it away for free to lazy people like me who can’t seem to get the grasp of coding php. Anyway, thank you thank you thank you thank you a billion times, you’ve made my day 50 times over and I can’t really thank you enough!

  15. [snarky wordpress moderators]

    Fran points up a crying need for some proper WordPress forums or even a WP Listserv.

    The current forums are an embarrassment to all involved.

  16. Hey Rob – I keep getting this error when trying to access the admin panel on the plugin:

    – Cannot load recent-posts.php.

    I have the most recent version of this plugin and the post plugin library on my wordpress site. Any ideas what could be wrong? Thanks. – Josh

  17. FYI, I was looking around the comments and saw the problem might be my php.ini memory limit. It’s at 32M so that seems like it should be more than enough. I still get the error.

  18. Okay, sorry for the multiple comments. Just tried downloading and installing an earlier version of the plugin – 2.5.0.11 – and it worked. I’m on WordPress 2.5 so maybe that was the problem?

  19. unfortunately the plugin writes “Recent posts” in the title in the sidebar

    I use the actual version but I could not find a setting to define a german title for that, so I had to hack the plugin itself

    this is a pity, many plugins and themes define the output in the code itself and don’t keep in mind that there are more than one language ;=(

    if I overlooked another comment here concerning the same topic, please forgive me, it’s late in Germany

  20. Connie, not true πŸ™‚ You can specify the title of the widget (provided you do use widgets).
    Mine says “Neueste BeitrÀge”.

    BUT: in WP 2.7 posts that are not yet published appear in the list. That is really annoying since it leads to a 404 page.

  21. Is there any Way – i show Gravatars also – to show an defined other gravatar then the one from gravatar.com (the man in grey)

    For Comments @ posts i have allready an other Pic instead of the standrad gravatar..

    THX Marv

  22. Hi Rob,

    Thank you for the great plugin series. Good job.

    FYI:: When I enter to the ‘Filter’ setting page, I found this error message:

    
    Warning: str_repeat() [function.str-repeat]: Second argument has to be greater than or equal to 0 in /home/tetesemb/public_html/wp-content/plugins/post-plugin-library/admin_common_functions.php on line 598
    

    Thereis 7 replications of that message on ‘Filter’ page, and it’s happened on all the plugin-filter-setting page.

    They’re shown after text ‘Categories to exclude/include:’ and before list of categories.

    What is happened, and how to solve that ?

    Filter setting is normally. Running well, but what is the error mean?

    Thank you. Jesus love us.

  23. Hi,

    Firstly, thank you for creating such an awesome plug-in! Unfortunately for me, I can’t seem to get the plug-in to work exactly the way I want it to. For example, I am trying to alter the code so that my recent posts display such that 2 are on the left and 2 are on the right, creating two separate columns. Is there any possible way for me to do this?

    Thank you!

  24. Hello it’s me again (comments #176+177).
    And after just saving a draft it showed up in my recent posts list.
    That is annoying since I often write posts over several before pubslishing them.

    Any ideas?

  25. I’ve got code appearing in the display of a user name

    John <span id="high_3" class="searchterm3">OÒ€ℒBrien</span>

    How do I strip or prevent that?

    Thanks

  26. 1- Can I have previous / next link ?
    1a- and without page refresh

    2- Can it show snippets of the recent posts ?

  27. I am using the Recent Post plugin, however I don’t see an available tag to place a link for the recent post comments, or posting a comment. Please let me know if there is a tag for this in the Recent Post plugin… all I see is the {commentnumber} or something like that

  28. Again about the draft issue.

    Since Rob seems so be overwhelmed by the success of his plugins I have added a few lines myself. I wrote about it on my blog. It is in German thought but if anybody wants the details I can translate the post.

  29. Im using a page as a static frontpage, now i would like do display the 5 last posts on this frontpage, but i cant get it to work, do you have any ideas?

  30. Hi. Can this plugin support WordPress MU? Meaning, can I use it to aggregate recent posts across all my WordPress MU blogs? If so, can you please advise how? Thank you.

  31. I’ve just installed this plugin, it works just half.
    The recent posts titles are showing up in the sidebar, but when I want to customise the plugin I got an error message: Can’t load the recent-posts.php.

    worldpress 2.7.2

    thanks for helpful answers

  32. I am thrilled to find this plugin, it allows the customizing I need to satisfy a very picky designer. I’ve got things pretty much as needed, but I can’t seem to remove the date from the bottom of the excerpt, designer wants it above. this is my output template

    {date}
    {title}
    {excerpt:30method:more:link}

  33. Hi again,
    With a little more playing around with the output the date is now where we want it, but the “more” link is not working. I know I’m overlooking something simple here……

    Thanks!

  34. Hi! Thanx for a great plugin!
    I’ve used some of the code

    post_date)) / (60*60*24)) + 1;
    recent_posts(“age-direction=before&age-duration=day&age-length=$post_days”);
    ?>

    to use on my site – i’ve tried to make it display recent post from the days before – here is the code:

    $post_days = floor((time() – strtotime($post->post_date)) / (60*60*24)) + 1;
    recent_posts(“age-direction=before&age-duration=day&age-length=$post_days&limit=3&output_template={link}”);
    $post_days = floor((time() – strtotime($post->post_date)) / (60*60*24)) + 2;
    recent_posts(“age-direction=before&age-duration=day&age-length=$post_days&limit=3&output_template={link}”);
    $post_days = floor((time() – strtotime($post->post_date)) / (60*60*24)) + 3;
    recent_posts(“age-direction=before&age-duration=day&age-length=$post_days&limit=3&output_template={link}”);
    $post_days = floor((time() – strtotime($post->post_date)) / (60*60*24)) + 4;
    recent_posts(“age-direction=before&age-duration=day&age-length=$post_days&limit=3&output_template={link}”);

    But something is wrong – and i don’t know how to repair it..
    Can you please help? (Ex. today – 20, yesterday 19 and so on..)
    1. it gets the time of the current post,so if i want to show post from yesterday (19) i have to be on the main page or on the page with the post that was posted today (20). If i open post that was posted on 15th – plugin shows posts from 14th – that’s wrong πŸ™
    2. is it possible to make it show post only from current date? Because if i have limit 3 and i had only 1 post yesterday it will show 1 post from yesterday (19) and 2 from 18.

    I hope you can help…

    Thanx, Max

  35. printer’s problem with {image} (as well as latest plugin version, I had to downgrade to version 2.6.0 to get this plugin to work at all) are EXACTLY the same as mine. I did a little CSS workaround that worked very nicely for me and was simple to execute.

    Rob, none of your solutions worked at all for me. {image:width:height} did not work, it just printed it instead of displaying the image.

    Here’s my fix.

    Create a div ID in your CSS stylesheet as follows:
    #myrecentthumbs li img {
    width: 180px !important;
    height: auto !important;
    }

    This will force all images displayed as line items in the div to size down to whatever size you want.

    In your options page, you would then add the surrounding divs to your {image} tag as follows:

    {image}

    Voila. It works! So happy to have found this plugin. Post-thumbs-revisted (which I also used before) really isn’t up to par and simply stopped working one day. Creating actual thumbnails is a real hassle for people who don’t know how to, or cannot access, their php.ini files to adjust memory limits. Always has been a bit of a problem for me even considering I know what I’m doing!

    I LOVE THIS PLUGIN. Very very very sweet, thoughtful and easy to use. Great work Rob.

  36. Urgent:
    Can anyone tell me if this plugin is compatible with WP 2.7.1? Or even 2.6.5?
    I run WP 2.6.2 and have just been hacked so I need to upgrade – and eventually look for a replacement plugin.
    Would be too bad since both this and Random posts work great.

    The plugin is said to work up to 2.6.2 – and it seems like people have different experiences… Any updates, Rob?
    Thanks,
    Kjetil

  37. Yeah, this is a great plugin, and would love to know if it’s still getting updated. On the WordPress site, it says something like 150 days since the last update…

  38. Hi Rob, first of all your plugin is excellent. But, I have a problem wiith the thumbnails. They show up correctly but there is a slight problem at the surrounding frame. I suppose it is a css prblem but i just can’t find the solution. You can have a look at my site’s footer and u will understand what I am talking about.

    Thanks
    Nikos

Comments are closed.