UPDATE: If you have the Jetpack Plugin installed, all you have to do is add ?random
(a URL param) and it’ll (contextually) randomize a single post. Wow. I had no idea. Thanks Chuck!
ANOTHER UPDATE: Jetpack has removed this feature now, so below might be useful again.
All I do to make this work on this site is make a page template:
<?php
/*
Template Name: Random
*/
$args = array(
'orderby' => 'rand',
'numberposts' => 1,
'post_type' => array(
'post'
),
);
query_posts($args);
while (have_posts()) : the_post();
header('Location: ' . get_permalink());
endwhile;
?>
Code language: PHP (php)
Then publish a page at that URL using that template.

Thoughts?
Email me or comment below.
Also CodePen PRO is quite a deal. š
Nice trick!
For all the lazy people ā here’s the link: https://chris-coyier.mystagingwebsite.com/random
https://mastodon.social/@samedwards/111495215548467041
?random works on WordPress by default! :-)
https://chriscoyier.com/?random
I’m pretty sure this works in context, too. So if you append to the end of a category or tag archive page, it should return a random post in that category or tag.
WELL WOULD YOU LOOK AT THAT.
I’m literally going to delete my custom code for this since that is obviously way easier.
For anyone looking to do something like on their site, I should mention that this is not a core WordPress feature. It is in fact part of the Jetpack plugin.
The Jetpack feature is actually based on an old plugin that was developed by Matt himself some 17 years ago! Random Redirect plugin on WordPress.org
Thanks for the clarification, Jeremy!