News, views, tips and tricks on Oracle and other fun stuff

Introducing: Stumble Upon a Post

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("
    FROM $wpdb->posts 
    WHERE post_type = 'post' 
    AND post_password = '' 
    AND post_status = 'publish' 
wp_redirect( get_permalink( $random_id ) );
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.

Happy stumbling.

Filed in Oracle, WordPress on 22 Apr 07 | Tags: ,

Reader's Comments

  1. |

    Great content thank you.