Redirect URL to Post

How to Display a Random Post in WordPress?

The WordPress plugin Redirect URL to Post comes with a handy set of options to send your visitors to a random post.

dices photo

WordPress offers many ways how to display posts in random order1. Sometimes, however, you want to show one – and only one – random post.

There are several reasons why you may want to show a random post:

  • revive old content
  • give an equal chance to all authors
  • increase on-site engagement and visitor retention for a better SEO score

All you need is the free plugin Redirect URL to Post from the official WordPress repository. It offers caching of database results (default is 60 seconds) and many other advanced features that I will present below.

After you installed and activated the plugin, you simply add ?redirect_to=random to the end of your site’s URL. For example:

https://www.my-wordpress-blog.com/?redirect_to=random

Once you press enter, the plugin will automatically pick a random post and insert the correct URL.

This URL can be used in any menu or button. You can even send it to your newsletter subscribers.

Advanced Options

Higher Probability For Recent Posts

The feature I like most is the option to use a different probability for older and newer posts. Recent posts are naturally more interesting and relevant, so you may want to show them more often.

You will need two parameters: count to determine the amount of new posts that receive a different weight and bias to determine the percentage that these posts should appear.

Here is an example:

https://www.my-wordpress-blog.com/?redirect_to=random&count=10&bias=80

In this example the first 10 posts are picked with a probability of 80% and the rest with a probability of 20%. You can see in the example that only the first parameter is added with a „?“ while all the others use „&“.

Power users may want to check out the parameter offset that lets them skip the very latest posts.

Use Only a Subset of Posts

Sometimes you don’t want to consider all posts but only a subset. Fortunately, the plugin lets you filter by author, post type (e.g. products), time frame or others.

The following link lets you redirect to a random post that is older than 1 month but not older than 6 months. That way you can revive posts that are neither brand-new nor totally outdated. Relative time formats give you a powerful tool to determine a point in time.

https://www.my-wordpress-blog.com/?redirect_to=random&before=1%20month%20ago&after=6%20month%20ago

Note that „month“ is used in singular and that spaces are encoded as „%20“. Without spaces the parameters will be more readable.

https://www.my-wordpress-blog.com/?redirect_to=random&before=1 month ago&after=6 month ago

Track Random Redirects With Analytics

If you want to track redirected visitors with Google Analytics, you can add a tracking parameter that will be carried over to the final URL.

https://www.my-wordpress-blog.com/?redirect_to=random&utm_campaign=random_link

Supported tracking parameters are utm_source, utm_campaign, utm_medium, utm_term, utm_content, pk_campaign, pk_kwd, pk_source, pk_medium and pk_content

Summary

The plugin Redirect URL to Post comes with a handy set of options to send your visitors to a random post.

You can find more details and other possibilities of redirects in the documentation.

Photo by James Bowe

Show 1 footnote
  1. You can use for example a shortcode.

Check Out My Plugins:

Organize your tags in coherent groups and tidy up your tag cloud! Display your tags under tabs or in an accordion.

You will never want to go back to the times when your tags were all over the place.

FREE

Supercharge your tags! Tag your posts on two levels with tag groups. Filter your posts on the frontend. Let your visitors search in real time by tags and groups.

Go directly to your first, latest or a random post just by adding some magic words to your site's URL. Search posts by author, or category, or something else. Or combine a time frame with search parameters.

FREE

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

Christoph