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!

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 Comments

  • 1. Rob  |  September 15th, 2008 at 8:01 am

    Phil: Just took a look at your web site… those naked codes don’t look like they belong to this plugin… have you by any chance upgraded to the wrong plugin?

  • 2. Rob  |  September 15th, 2008 at 8:09 am

    Kjetil : Sorry — I should read my own documentation! Instead you should wrap the image in a link of your own creation, e.g.,

    <li><a href="{url}">{image:0:50:?}</a>{link}</li>

    That should give the image a link to the post. You probably want to add other attributes to the a tag.

  • 3. Kjetil  |  September 15th, 2008 at 7:29 pm

    !!!
    Thanks
    <li><a href=\"{url}\">{image:0:65:65}</a>&nbsp;{link}</li> works like a charm. Just adjusted the width/height and added a space between the now linked image and link.
    The only thing I\’ll have to do is go through the posts for top images that are aligned right. Also those generated thumbs are aligned right. Just a minor adjustment…
    Wheres the donation button?!

  • 4. Rob  |  September 15th, 2008 at 9:18 pm

    Kjetil: I guess my subtle donation link on the settings page footer is just too subtle 😉

  • 5. blog  |  September 16th, 2008 at 3:17 am

    I want to add rel=”nofollow” but how ?

    thanks

  • 6. Rob  |  September 16th, 2008 at 9:59 am

    You just have to build the link from pieces:

    <a href="{url}" rel="nofollow">{title}</a>

  • 7. Kjetil  |  September 16th, 2008 at 10:21 pm

    I\’m sorry, but that link doesn\’t work. In my case it points to http://www.dolcevita.no/donate/random-posts/ – which doesn\’t exist.
    Just provide a direct link – it could be useful for others too.
    :o)

  • 8. Rob  |  September 17th, 2008 at 10:55 am

    Kjetil: Thanks for spotting that error of logic! I will fix it in the next release. meantime if you want to donate try: http://rmarsh.com/donate/random-posts/

    Thanks!

  • 9. Kjetil  |  September 17th, 2008 at 6:40 pm

    Works!
    Well done.

  • 10. Javier  |  October 4th, 2008 at 2:03 am

    Wow.. you have done an awesome job with this plugin! Do you have a donations paypal address? It’s amazing, you can format the random exactly as you want, even if by custom (Image) field exists, exactly what I needed!

  • 11. Rob  |  October 4th, 2008 at 10:43 am

    Javier: Thank you very much!

    There is a donations link at the bottom of the plugin’s settings/options page. I tried not to make it too distracting but I’ve obviously overdone it 😉

  • 12. Javier  |  October 4th, 2008 at 1:34 pm

    Thanks Rob,.

    i see an answer for this question about displaying the plugin in different places, but I don’t understand how it works. I tried pasting the code but got nothing.

    e.g., random_posts(‘limit=3&output_template={custom:another_field}’)

    Is it possible to not only format differently but also filter for this second display of script?

    If not, could I install a second folder with the same plugin files and change some values to have two different plugins?

  • 13. Rob  |  October 4th, 2008 at 2:50 pm

    Javier: If you invoke the plugin without a parameter string, random_posts(); all the options set from the settings screens apply. But if you can also invoke the plugin with a parameter string and the parameters you supply will override those set from the settings screens. There is a lot of information on the configuration page. You can use the parameter string to change almost all the settings, including the output template.

    Cutting and pasting the example you quoted would not get you very far because it was specific to that particular need.

  • 14. Javier  |  October 5th, 2008 at 1:08 pm

    Great thanks, is there any way to display the top category? (isntead of the immediate category a post is in)

  • 15. Rob  |  October 6th, 2008 at 8:54 am

    Javier: I am a little unclear on the definition of the top category. Do you mean the highest in the hierarchy of any category labels actually assigned to a post? Or are you thinking of tracing up the hierarchy in some way?

    Secondly, what would you want displayed: id, name, link?

  • 16. Kjetil  |  October 8th, 2008 at 9:01 am

    Hello again
    I have a problem with some posts I do not wish to display.
    In your very detailed instructions you say that
    “Beware of choosing settings which are contradictory (e.g., include and exclude the same post)”
    The posts I want to exclude are assigned to two categories – eg maps and regions. I want to show no maps posts but all regions post. I cannot un-assign the maps away from its region’s category (since eg the Veneto region map should show up on that Veneto’s overview page).
    Any way to achieve this, or should I just live with it?
    Thanks,
    Kjetil

  • 17. Aysseline  |  October 27th, 2008 at 9:51 am

    Hi, I’m using random_posts and I want to know how I can random posts only from one cat. I trying diiferents code but nothing run.
    if (function_exists(‘random_posts’)) random_posts(‘cat=10’);

    if (function_exists(‘random_posts’)) random_posts(‘category=name’);

    I search on doc but cant really know how to do this. Thanks for your help.

  • 18. Embun  |  October 29th, 2008 at 4:34 pm

    Too much love to omit this great plugin thanks.

    There is a little problem for mine.
    I have about 20 post categories. In your admin-filter page, the ‘Random-Post’ filter option shows just 13 categories.

    Where are the remaining categories left?

    case:
    I want to exclude some categories, but I didn’t find them in the choice list. So, the posts under undesired categories, still generated in Random-Post section.

    May I get help for this??

    Regards.

    PS: I have a bad English grammar. Hope you can understand.

  • 19. 78hg  |  November 6th, 2008 at 10:16 am

    Thanks, when install it need “Post-Plugin Library.”?

  • 20. lutfi  |  November 13th, 2008 at 12:38 pm

    Hi,

    Is there any way to make this plugin run faster? It need more than 3s to generate random post (for 1 random post)

    By the way, great work.
    Thank you.

  • 21. morrisjfwong  |  November 19th, 2008 at 1:31 am

    Hi, this plugin is really useful.
    Just 1 question: can I generate random post for specified category ?
    Thanks.

  • 22. Bas  |  December 8th, 2008 at 5:12 pm

    Hi all!,

    How to show an image by a random post?

    i’m using now:
    <li><li><a href="{url}">{custom:thumbnail-alt:0:65:65}</a>&nbsp;{link}</li></li><br>

    But my pictures from each post are stored into the folder:
    wp-content/uploads

    if i want to show the article thumb, i see only the images that appears into my post, and not the thumb.

    How to fix this?

  • 23. Bas  |  December 9th, 2008 at 3:23 pm

    Someone?
    My post with detailed information is removed.

    Please tell me the solution.

    Regards,

    Bas

  • 24. Bohumil Stejskal  |  December 28th, 2008 at 10:11 pm

    I have same problem as morrisjfwong, but i dont know, how do it

    I need to display random posts in actual categories… Same with popular post plugin. I think, its easy, but i dont see it here :(

    Thanks for reply and for great plugins

  • 25. Bohumil Stejskal  |  December 28th, 2008 at 10:25 pm

    For better specifikation: I need random posts from all categories on homepage and single pages, but in categories i need only random posts from specified(actual) category

  • 26. Bohumil Stejskal  |  December 28th, 2008 at 11:53 pm

    Heh, I know how to…
    For anyone, who has same problem:

    In category code use:
    <?php $ide = $cat; popular_posts("included_cats=$ide"); ?>

    Sorry Rob for three comments. And thanks for awesome plugins!

  • 27. Dave  |  January 7th, 2009 at 6:13 am

    Is there a way to display a horizontal list of 1-5 random posts on my non-Wordpress home page?

    Thank you!

  • 28. San Diego Tim  |  January 12th, 2009 at 11:57 pm

    For those looking to upgrade to WP 2.7, I had no problems with this great plugin when I upgraded.

  • 29. Digigirl  |  February 17th, 2009 at 4:35 pm

    Hi Rob, the plugin works great! I’ve set it up to just show the image and link to the article and it’s working fine.

    One problem I am having though – I have it set to show 4 links and no matter what I do, it continues to show 5, which makes it break onto a second line and run into the next widget down.

    Is there something else I need to do to keep it to 4 posts besides just choose 4 in the Settings screen?

    I am using WP 2.7.1. Thanks!

  • 30. Jason  |  March 1st, 2009 at 11:28 pm

    Hi Rob,

    When I move my cursor into displayed post tilte, then the date when the post created will appear. I do not want visitor see the date. How to change this?

    I try to see outout tags.php, but I don’ t know what to do.

    Please advice. Thanks. Great Plugin!

  • 31. Michael Soriano  |  March 13th, 2009 at 4:29 pm

    Hi Rob,

    Is there any way you can just grab the last 30 posts and randomize it?

  • 32. topmaxtech  |  May 21st, 2009 at 5:52 am

    thank u very match

  • 33. Markus  |  May 22nd, 2009 at 2:50 pm

    Is there a chance to get a tag like {authors_gravatar} ?

  • 34. Markus  |  May 22nd, 2009 at 5:31 pm

    sorry, i have solved it on my own:

    At the function otf_author($option_key, $result, $ext) I added the case “gravatar” like …

    case 'gravatar':	
    
           $author = get_avatar( get_the_author_email(), '20', '' );
    
    		break;
    

  • 35. Kjetil  |  May 27th, 2009 at 8:49 am

    Urgent:
    Can anyone tell me if this plugin is compatible with WP 2.7.1?
    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 Recent posts work great

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

  • 36. Kjetil  |  May 27th, 2009 at 8:49 am

    PS and what about 2.6.5? Does it work there?

  • 37. emacrisema  |  June 15th, 2009 at 5:25 pm

    How could I add an image through an custom field (I don’t want the image in the post) that is also clickable ?
    Thanks

  • 38. Talamentes  |  June 16th, 2009 at 1:28 am

    Thank you, it was really usefull, but it would be perfect if it could also include an image from the post

    it would be more atractive for the viewers

  • 39. Digigirl  |  June 16th, 2009 at 2:37 am

    I figured out to add an image.

    Go to Settings>Random Posts Options>Output

    In the Output Template field, I put {custom:minithumb}

    Then on each post, I do a custom field called Minithumb and put the url of my image. Mine is sized 65px x 65px. You can see the result on my web site at the top of the right hand sidebar.

    I am only putting the image there, which links to the post. You could add the title but I don’t know what to tell you on how to format it to output properly. Good luck!

  • 40. Adam  |  June 16th, 2009 at 12:17 pm

    It’s possible to set, that pugin will display only posts not older then (some date) or last 3 monts, or something similar?

  • 41. Lee  |  November 17th, 2009 at 12:08 am

    Hi Rob
    can you explain how to configure the code systax in order to;
    Create 4 widgets, each widget will have 1 of the these category (1,2,3,4) assigned to it.

    The post title will bea link to the full post. the content will be 50 word snippet and will have the suffix “continue reading” which will be a link to the full article.

    I have been struggling to put this together

    Lee

  • 42. John  |  August 31st, 2011 at 6:44 pm

    Is it possible to exclude the category on the source post? What I mean is if the post a visitor is looking at is from the category NEWS, the random posts displayed should never be from the same NEWS category. Can this be done somehow? However, I don’t want to block the News category altogether, since random posts should be displayed if somebody comes from another category.

    PS. By the way, excellent plugin. Very easy to set up.