Random 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 posts chosen randomly from your blog.

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

Please note the new upgrade instructions!

  • 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.0.1 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 an option to match the current post’s author and 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, to {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 a filter problem 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 many 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 can be used as a WordPress 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.

Random Posts lets you put on display some of the posts that might otherwise get lost deep in your archives and, hopefully, get visitors to explore your site more thoroughly.

The plugin has an settings 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 Random Posts.
  4. Put<!--?php random_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|Random Posts pages to set all the available options. Alternatively, the options can be overridden by passing a parameter to the random_posts template tag.

Usage and Options

The configuration page will help you to set up the plugin to your satisfaction.

142 replies on “Random Posts”

  1. hello,

    this plugin nearly matches what i was looking for.
    but to be honest i would prefer to write an include-list instead of a list of posts to exclude. because i just want to display some of the best articles so far randomly. since i have nearly 500 posts it would be a lot of work to exclude a majority instead of including a small collection. 🙁

  2. @ rob: that sounds very promising 🙂
    maybe you like to consider to add this option in one of the next updates, perhaps it is possible to put it in some kind of “reverse mode”, giving the list the opposite function (using it for including instead of excluding). that would be brilliant.

  3. Ok i think there is a BUG, when i try to remove the widget from the sidebar, i can’t because the menu is not there. The edit button is missing. I use wp2.5. All other plugins from you work correctly

  4. Partz Partzescu: I can’t reproduce that behaviour myself. Can you make a bug report from the settings screen of Random Posts because it will tell me stuff about version numbers, etc.

    I would also advise uninstalling the plugin completely and installing the latest version.

  5. Rob,

    I had been using this plugin without any hiccups until just recently. To be honest, I don’t know when it simply disappeared from the sidebar — but I noticed today that it was gone.

    So I checked the configuration page and I also took the widget off the sidebar and put it back on. No luck.

    Then I put the php code in a php enabled widget, but still no luck. The random posts pluging just won’t come out and play. And it’s such a great plugin too, I think it’s done a lot for my ‘how-long a person sticks around’ stats.

    Any suggestions much appreciated.

  6. Rosina Lippi: Can you tell me what version of WP and of RP you are using? And can you tell me if anything else has changed recently — updates, new plugins, etc. Thanks.

  7. Sorry Rob, I should have thought to include that information.

    I’m on the most recent, up-to-date versions of WP and Random Posts (2.5; 2.5b19). I do have a lot of plugins installed. Are there any in particular that don’t get along with Random Posts?

  8. Rosina: I’ve had the odd report of the recent posts plugin not doing well with wp-cache. I was just wondering whether anything notable had changed which might help me get to the root of the problem.

    Could you make a bug report through the settings screen as it provides some extra information that might help.

  9. Love the idea of having a random post widget. I went through all the steps, installed and activated the necessary plugins. Added the widget to my sidebar, and it messed up the whole page (which I half expected because the site is currently using a pretty complex theme). But the real problem is that now I can’t get rid of the widget.

    As I look at my design-widgets screen, I added the Random Posts widget. It moved over to the right of my screen and says that I am now using 1 widget. After I discovered it wasn’t working, I wanted to remove the widget, but leave the plugin for now. But I can’t for the life of me figure out how to remove the widget. Is there supposed to be a way?

    As of right now, the only thing I can do is deactivate the plugin. That removes the widget from the right side of my design-widgets screen, but it still says that I am now using 1 widget.

    Is it normal that once you add this widget you can never get rid of it short of getting rid of the plugins? Thanks for any help you can offer.

  10. I now realize I brought this on myself by not closely following the above instructions.

    But that said, I really don’t know what do it. I completely deleted the plugins, and it still says that I’m using 1 widget (but there’s nothing there).

  11. Ace: Is everything working properly now? If the widget is not showing the ‘edit’ link to let you remove it something has gone wrong.

    As for WordPress telling you there is a widget inuse when there isn’t … that seems to be a WordPress bug.

  12. Hello,

    Thanks for your work, i really appreciate.
    Just a silly question: What is the string name to unable WPcache to cache the radom post (i use the thumbs)?

    Best regards

  13. kca: I’m sorry I don’t understand. The WP-Cache plugin will cache the output automatically. Is that what you mean?

    My own Plugin Output Cache won’t automatically cache the Random Post output because I wanted to keep it dynamic.

  14. KCA: Ah! I tried that myself a while ago and basically found I had to include so much of WordPress that it wasn’t worth it. I seem to remember I had to include some path information in the string but I can’t be sure.

  15. Thanks Rob,
    guess what? I will just keep it simple. I am already satisfy with the plugin, and it will not be too hard for me, to just clean up the cache 1 time/ day at least ^o^

    Best Regards

  16. Hi Rob: thanks for the great plugins!

    I’m using RecentPosts on a site & have employed the tag {categorynames} to display the category (or categories) in which a listed post resides. However, when a post resides in multiple categories it lists the category names back-to-back with no spaces. For example, a post within the categories of “News” and “Reviews” shows up as “NewsReviews”

    Am I doing something wrong? Or is there something I can edit to make it display properly?

    Thanks!

  17. My sidebar is already crowded

    Is there anyway I can just put a text link “Random Post” on the side bar (preferably in the next row under my Search button), and when people click on these words the random listing appears on a new page/post to the left?

  18. rick davies: There a number of ways of doing that. Perhaps the easiest is to make a new page dedicated to the random listing and use the embedded tag <!--RandomPosts--> somewhere in its content. You would need to switch on the content filter to have it appear. Then just put a link to the page as normal in your sidebar.

  19. If you had the misfortune to download version 2.5.0.7 you may run into problems when you try to update to a newer version. I managed to introduce a circular dependence between this plugin and the Post-Plugin Library which means trying to update either from the admin plugins page will cause an error. Instead you need to delete the 2.5.0.7 version from the server (Post-Plugin LIbrary too) and upload the newer one and the problem should be solved. I apologise for any worry or inconvenience.

  20. Hi Rob.

    I’m looking forward to trying out this new plug-in. I currently only have 2 posts on my new blog, so it could be some time… but I think it’s a great idea.

  21. Is there any way to get the image src title?

    Also, can I put {imagesrc} in a replace function?

    Thanks for this plugin. It’s great stuff.

    amdg

  22. Jude: Nice site!

    I’m sorry to say those abilities are missing right now. If you can tell me more exactly what you are looking for I might find that they would be easy to implement.

  23. Thanks!

    Basically I want to get {imagesrc} string and replace “.jpg” with “-150×150.jpg” so it ends up displaying the thumbnail that wordpress generates when I upload pictures.

    imagesrc title was also an option because it’s the same as the image filename (without the file extension).

  24. Jude: I think the best solution from my point of view would be to allow output tags within the {php} output tag. I’ve already done that for the {if} tag so it shouldn’t take much effort.

    An alternative might just be to make an output tag {thumbsrc}. Does WordPress always use that naming convention–i.e., is it always 150×150 or can the size vary?

  25. Jude: Version 2.5.0.11 has beefed up the {php} tag to allow tags to be used in code, e.g:

    {php:echo str_replace('.jpg','xxx.jpg','{imagesrc:0}');}

    Note the quotation marks around the {imagesrc} tag.

    By the way — I’d still consider making a tag to do the job directly if you can help me with some information.

  26. Rob, works perfectly. As a quick workaround, I added the replace function in the output tags php but the new updates are definitely a much slicker solution.

    The thumbnail size is user-defined in settings > miscellaneous. 150 x 150 seems to be the default size

    Thanks!

  27. Hello, Rob. Firstly, congratulations for your plugin. It look likes very useful. So, we have a page about Brazilian television and we use a code to random posts. But, this don’t work very well, because display old posts. With your plugin, we’ll can set to WordPress display only the news most recentlys? Thank you.

  28. Ciao! – and thanks a lot for some very useful plugins.
    I wonder if this is possible – probably with the Random and Recent posts plugins:
    First: On my front page I\’d like a (small) sidebar with a list of random posts – but the first one should also include a thumbnail – of the first image in that post. (If not possible a thumbnail from each of the shown posts could work.)
    Second I\’d like a 4-column row of the most recent posts, each of them with a thumbnail above.
    The latter already is in place on our site but is made manually in html – the first is a much-wished addition to make people discover \”hidden\” parts of the site.
    Any way I could do this? I would be most grateful.
    Thanks,
    Kjetil
    PS I\’ve tried the 150×150 procedure mentioned above (after uploading a 500px image to a post) but no 150px thumbnail is generated (I\’ve checked the Miscellaneous settings – and the uploads folder). So, no thumb to be inserted. (This is tested locally, but I can\’t see that this happens online neither.) Probably missed something.

  29. Just to add in:
    I found the instructions for
    {image:number:width:height:timing:link:default}
    which might be useful, but I just can’t figure out how to mix it with eg the function

    An example, mayby, with ‘s ,s and spaces?
    :o)

  30. Kjetil Flekkoy: I’m afraid we lost some code there in your second comment so I’ll have to pass over it.

    The random posts list for the front page should be easy as long as you are willing to accept an image with each item. A good practice is to play around at first with a simplified version — try using an output template of <li>{link}</li> to get the general idea and then, when that is working, introduce the {image} output template tag. I’m guessing you want something like:

    <li>{image:0:50:?}{link}</li>

    This should pull the first image in your posts and scale it to be 50px wide (choose your size). I don’t think you need the other parameters.

    The other list you want is probably the same: the difference will be the size of the thumbnail and the css which you apply to it.

  31. Thanks a lot – this was of great help.
    First of all I had not understood that eg the image code should be inserted in the settings panel (instead of some php/template file). Then you cleared up how to mix the image code. Looks promising. Great!
    Now, could I somehow make also the thumb image before the link clickable; that is, put a link also on the thumb?
    (Think I\’ll have to come back to the bottom recent post/image row – as is here now)
    Kjetil
    The code that fell out was just the little snippet one has to insert in a template to call eg the random post list into a page. Trying again: \’\’

  32. Great – thanks for responding so quickly.
    The linking works, but now – strangely enough – all the thumbs are created from just one out of two images – images mostly (of course) belonging to other posts.
    Could there be something wrong regarding the code in the posts that the images are pulled from? I ask because as I understand it, entering eg {image:0:65:65::link} only will work if the mother images are wrapped in links. As you say in your very thorough post-options page: “If the link parameter is given as ‘link’ then only images wrapped in links will be extracted and displayed.”
    (My initial thought was a plugin conflict: Its a weired behaviour and I have lots of plugins (ca 40) running on this complex site.)
    Thanks again,
    Kjetil

  33. I was using the older version of \”Recent Posts\” and just updated to the latest version. Now I just see the code instead of the posts. It\’s been so long since I configured it I can\’t get it right.

    Thanks,
    Phil

Comments are closed.