Looks like you’re after Random Post Link.
For completeness here’s some code (the plug-in is a little more involved as it stores as a cookie previous random posts, so they don’t twice).
(The following is based on the above plug-in by Scribu)
//Create random url - use this where you want the link to be displayed
$url = add_query_arg( 'wpse82608', 'random', trailingslashit( get_bloginfo( 'url' ) ) );
printf( '<a href="https://wordpress.stackexchange.com/questions/82608/%s" > Random Post </a>', $url );
Then interpet the random url (this can go in a plug-in or, if you must, your theme’s functions.php
)
add_action('init', 'wpse82608_random_post_redirect' );
function wpse82608_random_post_redirect(){
if( empty( $_GET['wpse82608'] ) || 'random' != $_GET['wpse82608'] )
return;
//Get a random post
$posts = get_posts( array(
'orderby' => 'rand',
'showposts' => 1,
));
//If no posts founds - redirect to site.
if ( empty($posts) ){
wp_redirect( get_bloginfo( 'url' ) );
exit();
}
//Get the random post's ID
$id = $posts[0]->ID;
//Redirect to post
wp_redirect( get_permalink( $id ) );
exit();
}
This is untested.