AJAX Random Posts - a new WP plugin (of mine)

Firstly, I’d like to show off a bit: hey I’ve caught up with the crowd, now both of my sites (this one and Thica.net) are upgraded to WordPress 2.7 - well, let’s hope that it is not prone to new vulnerabilities. The most significant change is the admin section - for the first time in my life I have to admit that it looks even better than the front-end. Is it good, or is it bad (my baby), I don’t know, but if you are using my plugin(s) and are worried about the compatibility, rest assured: they all work in this new versions. That is, of course, unless you tell me that they’re not.

But hey, this post is not about WordPress 2.7! There are hundreds of blogs out there babbling about it already! If you’re a careful reader (definition: a careful reader is someone who reads something from the title on), you probably know it, I’ve managed to used some free time to write another WP plugin called AJAX Random Posts, and this post is more or less its homepage.

As its name is saying, AJAX Random Posts (AjaxRP) display a list of randomly chosen posts from your WordPress-powered blog. Yeah, it’s nothing new, such a concept is very popular and has been greatly done by several plugins before. The limitation of those plugins however, is the lack of cache plugins compatibility. For example, you install a random post plugin. Then a visitor comes to post A, and under a post he’s served with 5 other random ones, let’s say C, Y, M, K, and J. If you have WP-Super Cache enabled on your blog, the post A is cached for, like, one hour. During that one hour, any visitor that reads post A will be served with its cached version, with C, Y, M, K, and J following. You must agree with me, it’s not so random anymore :) .

So, the only difference my AjaxRP is making is its “AJAX” part. With AjaxRP, the random list is NOT generated along with post A. Instead, it makes an AJAX call to the server after the page is loaded (more precisely, after the DOM is ready) and retrieves a list of random posts. This way, it works regardless of whether or not you have a cache plugin installed. That means, each page refresh shows a new random list. And I guess that is what should be called “random”.

FAQ

Q: Do you provide a template tag/ post tag?
A: Absolutely. If you don’t want the random posts to be display after every post, just set “Automatically display the random posts in a single post page?” to “No” in the Settings page, and

  • Manually put <!-ajaxrp-> at the end of your post, or
  • Place this php code: <?php if (function_exists(‘ajaxrp’)) ajaxrp(); ?>
    at a proper place in your template’s single.php page

Q: Where can I find a demo?
A: Right here! Take a look at the end of this post.

Q: How do I support this plugin?
A: Please link back to this post or blog about it. Also I would appreciate a lot if you can rate this plugin 5 stars in the WordPress repository.

History

Full history can be found here.

Download

Head here.

  • checking your comments I’ve seen that it has to be inside the loop… I’ve been trying to put it manually on a sidebar, but no success =( The thing is, besides MCE, which you also use, I use smiles-themer and smiles-toolbar, but if I activate your plugin on auto, I get a conflict between smiles-themer and ajaxrp on:

    Warning: preg_replace() [function.preg-replace]: Empty regular expression in (etc)/wp-content/plugins/smilies-themer/smilies-themer.php on line 95

    If you don’t mind taking a look, smiles-themer homepage is here http://rick.jinlabs.com/code/smilies-themer/ and toolbar is here http://polpoinodroidi.com/wordpress-plugins/smilies-themer-toolbar/
    I really have no idea about editing plugins, so I wouldn’t even know what to look for. Thanks a lot, and congrats on such a great plugin! I hope to find a way around, don’t wanna stop using those smiles =p

  • Can fix something to list posts only from certain categories?

  • …I wanna try it..

  • Pretty nice ajax plugin, thx!

  • thank you , best plugins

  • Thanks for sharing this brilliant plugin. I will try it for sure!

  • thanks for plugin,
    i search for code of random posts ?

  • So far so good on plug in… You worried about wordpress 3.2?

  • Any thought on keeping this plug-in updated?   One of the few that I have found that really does what it says….

You can follow any responses to this entry through the RSS 2.0 feed.

Trackbacks / Pingbacks