It’s the season of stumbling:
StumbleUpon, in its most recent toolbar, introduced a new feature called StumbleThru, which allows users to stumble through pages on a specific web site.
Google introduced a recommendations button that you can add to the Google toolbar. The button looks like a pair of dice. Every time you click on the dice, you will be taken to a site that may be interesting to you based on your past searches.
Matt Mullenweg introduced a new WordPress plugin, Random Redirect, which is a special URL that, when clicked, will redirect to a random post on your blog, in a StumbleUpon-like fashion.
I have activated the Random Redirect plugin on my blog. Every time you click on this link you will be served a random post from the list of all my previous posts. You can also find this link on the blog’s top menu bar.
Out of curiosity, I took a look at the code behind the Random Redirect plugin, and amazingly, it is very short and simple. Here it is, the whole plugin:
function matt_random_redirect() {
global $wpdb;
$random_id = $wpdb->get_var("
SELECT ID
FROM $wpdb->posts
WHERE post_type = 'post'
AND post_password = ''
AND post_status = 'publish'
ORDER BY RAND() LIMIT 1");
wp_redirect( get_permalink( $random_id ) );
exit;
}
if ( isset( $_GET['random'] ) )
add_action( 'template_redirect', 'matt_random_redirect' );
Notice the ORDER BY RAND(), this reminds me of one of my earlier posts: ORDER BY no order. Basically, you can do the same in Oracle: ORDER BY dbms_random.random.
Possibly related:
- Read XML from an HTTP POST
- A Sneak Preview of The New OTN Special Edition Web Site
- Bring your old posts to life
- Extract And Use Information From Any Website Without Any Programming
- Sequential GUIDs
Tagged dbms_random, plugin | Post a Comment


















Great content thank you.
June 11th, 2007, at 4:50 pm #