I love the random button. This site needs a random button.
Click here for a random wikipedia articles. Here’s there explanation below.
In Wikipedia and other sites running on MediaWiki, Special:Random can be used to access a random article in the main namespace; this feature is useful as a tool to generate a random article. Depending on your browser, it’s also possible to load a random page using a keyboard shortcut (in Firefox, Edge, and Chrome Alt-Shift+X).
To create a link to a random page in a different namespace, use [[Special:Random/Namespace]]
. For example, Special:Random/Talk will take you to a random article’s talk page.
This article is cool in that it explains a few of the implementation options including a custom shortcode. I used the custom query option to implement and it was pretty straightforward.
Here is an article that describes adding code to custom page template and inserting wherever using get-template-part function.
Another article here shows how to use 307 redirect in functions.php and then update permalinks. This option is cool because you can now just link to yoursite.com/random.
Of Course there is a plugin for this as well.
In WordPress there is next_post_link function and a previous_post_link function and it would be great if there was a random_post_link function to avoid this custom query code but implementation is easy enough I guess.