Prior to WordPress version 3.8, I had this wonderful little plugin called “Random Redirect” written by Matt Mullenweg. That little plugin served this blog, and Bionic Beauty, for over four and a half years! Sadly, WordPress 3.8 with Jetpack completely borked the use of Random Redirect and its successor, “Random Redirect 2”.
What’s a blogger to do? I LOVE my little “Surprise Me” graphic in the sidebar that whisks readers off to a random post. It’s simply awesome.
I set off seeking a replacement.
Then… a lightbulb moment! I already have the completely awesome “Redirection” plugin by John Godley. I’ve used it in the past to handle 301 redirects with ease.
In this case, we’re looking for a nifty bit of code to allow website visitors to click on a link (or image), such as the Surprise Me graphic in this site’s sidebar; the click action needs to trigger the code to magically send the visitor to a random article.
How to Make the Magic:
- Install the Redirection plugin by John Godley. Get it at Godley’s own website or from WordPress.org.
- Active the plugin.
- In your WordPress admin, select Tools, then Redirection.
- In “Add New Redirection” type:
http://your-domain.com/?random*Remember to replace your-domain.com with your own domain name.
- Set Match field to “URL only”.
- Set Action field to “Redirect to random post”.
- Tap that Add Redirection button to save!
- Head over to your theme/layout/code/wherever you’d like your redirect placed and insert the link using the code from step 4:
- For example:
< a href="http://bionic-style.com/?random" title="Read a random article on Bionic Style!">Random Post!< /a>. *If you copy/paste this code directly, be sure you remove the spaces after each “<“.
- Enjoy the wondrousness that is a surprise random redirect to one of your own articles!