Random Posts
Purpose
This plugin displays a list of posts chosen randomly from your blog.
This is version 2.5.0
. It is compatible with WordPress 1.5–2.5.
Please note the new upgrade instructions!
- 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
- 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 Random Posts.
- 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. - 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.
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
-
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.
27 Comments Add your own
1. Rob | March 17th, 2008 at 6:19 pm
2. dissi | April 3rd, 2008 at 11:15 pm
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. :(
3. Rob | April 3rd, 2008 at 11:20 pm
4. Partz Partzescu | April 3rd, 2008 at 11:39 pm
Hello Rob,
Can you please update somehow the plugin so i can modify the title of it, it appears Recent Comments but my blog isn’t in English so i have to say it in my language. Thanks!
5. Partz Partzescu | April 3rd, 2008 at 11:40 pm
I forgot, can you also add the number of posts that should show like in your other plugins?
6. Rob | April 3rd, 2008 at 11:56 pm
7. dissi | April 4th, 2008 at 12:06 am
@ 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.
8. Partz Partzescu | April 4th, 2008 at 10:54 am
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
9. Rob | April 4th, 2008 at 12:15 pm
I would also advise uninstalling the plugin completely and installing the latest version.
10. Partz Partzescu | April 4th, 2008 at 12:33 pm
Ok, no problem i’ll do it right now
11. Rosina Lippi | April 17th, 2008 at 4:53 pm
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.
12. Rob | April 17th, 2008 at 5:11 pm
13. Rosina Lippi | April 17th, 2008 at 5:32 pm
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?
14. Rob | April 17th, 2008 at 5:35 pm
Could you make a bug report through the settings screen as it provides some extra information that might help.
15. Rosina Lippi | April 17th, 2008 at 5:41 pm
Done. Thanks for your help.
16. Ace | April 23rd, 2008 at 1:28 am
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.
17. Ace | April 23rd, 2008 at 1:39 am
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).
18. Ace | April 23rd, 2008 at 1:52 am
Sorry for the triple post.
Conclusions:
1.) I’m an idiot.
2.) This plugin is awesome. Thanks so much.
19. Rob | April 23rd, 2008 at 10:53 am
As for WordPress telling you there is a widget inuse when there isn’t … that seems to be a WordPress bug.
20. kca | May 1st, 2008 at 10:00 am
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
21. Rob | May 2nd, 2008 at 10:52 am
My own Plugin Output Cache won’t automatically cache the Random Post output because I wanted to keep it dynamic.
22. KCA | May 2nd, 2008 at 11:48 am
Thanks for the quick answer.
Sorry lost in translation.
In fact my question is: How to keep the random post dynamic with WPcache?
23. Rob | May 2nd, 2008 at 2:36 pm
24. kca | May 2nd, 2008 at 4:42 pm
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
25. Rob | May 2nd, 2008 at 5:58 pm
26. Copernicus | May 14th, 2008 at 6:18 pm
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!
27. Rob | May 14th, 2008 at 9:36 pm
{categorynames: | }Leave a Comment
Trackback this post | Subscribe to the comments via RSS Feed