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. 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. 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. !!!
    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. 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!

  5. 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 😉

  6. 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?

  7. 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.

  8. 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?

  9. 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

  10. 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.

  11. 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.

  12. 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?

  13. 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

  14. 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

  15. 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!

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

    Thank you!

  17. 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!

  18. 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!

  19. 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;
    

  20. 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

  21. 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!

  22. 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

  23. 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.

Comments are closed.