Redirect URL to Post


Redirect your visitors to

  • a random post
  • your last (latest) post
  • your first (oldest) post
  • or a combination of conditions, for example a random post among your last 10 posts, or the latest post from at least 3 months ago, or the latest post of a specific author.

A magic URL takes you to the right post

This plugin provides an URL (link) that takes you directly to a post in single-post view. This post is determined by the query parameter ?redirect_to= and optional others.

While the URL remains the same, its target changes depending on the available posts at the time when somebody enters it. That means you can use the same static URL in a menu, with a button or in a newsletter and the plugin finds out the correct target.

Simply enter the URL of your WordPress site into your browser and add ?redirect_to=… to the end.

Possible values for redirect_to are:

  • last or latest – The URL will redirect to the last (latest) post.
  • first or oldest – The URL will redirect to the first (oldest) post.
  • random – The URL will redirect to a random post.
  • custom – The post will be determined according to the mandatory parameter orderby and the optional parameter order.

You can also limit the scope of considered posts by additional filter parameters, such as &s=searchaword or &cat=2.


The plugin offers caching of database results.

Settings and Parameters

There is no settings page in the backend. You configure the plugin entirely through the query parameters in the URL.

Please find more information about parameters and troubleshooting on the plugin website.

Examples for URLs

Note: Replace “” with your own website location. Spaces are written as “%20”. – redirects to the latest post – redirects to a random post and tracks the visit – redirects to a random post among the 10 latest posts – redirects to a random post. The plugin picks one from the latest 10 with a probability of 80% and from the rest with a probability of 20% – redirects to a random post among the 10 posts that come after the latest – redirects to a random post among the posts that are not older than 1 month,7 – redirects to the latest post, excluding the posts with the IDs 4 and 7 – redirects to the second latest post – redirects to the post with the most comments – redirects to the latest post that contains the word ‘iaido’ or, if nothing can be found, to the page or post with the ID 12; use a cache with a 200 second lifetime


The plugin also provides a shortcode [redirect_to_post_button] to create a simple button. Some parameters are available.

A button that links to a random post is a great way to increase your visitors’ on-site engagement and therefore your SEO ranking!

If you find this plugin useful, please give it a 5-star rating. Thank you!

Follow us on Facebook or Twitter.

Check out my other plugins


  1. Find the plugin in the list at the admin backend and click to install it. Or, upload the ZIP file through the admin backend. Or, upload the unzipped redirect-url-to-post folder to the /wp-content/plugins/ directory.
  2. Activate the plugin through the ‘Plugins’ menu in WordPress.

After the first activation you will find a screen with some examples of URLs for your blog.


1. What if more than one post match the criteria (e.g. two have the same comment_count)?

There can be only one winner. The post that would be first in the list (as determined by WP) beats all others.

2. Since WordPress version 4.8, the shortcodes in the widgets stopped working correctly

That is a problem caused by the new editor in WordPress widgets. You can avoid it by using a text-only widget, like Classic Text Widget

3. The random parameter redirects always to the same post

You probably use a caching plugin or service that also caches query strings. Try adding an exception for the string “redirect_to=”. If you use Cloudflare, you can try their Page Rules.

4. Which URL can serve as the base?

Obviously only URLs of the WordPress blog where this plugin is installed.

5. The post cannot be found but I’m sure that it’s there and that it’s public

The most common reason is that this post belongs to a special post type. Try the parameter “post_type”, for example “post_type=product”.

6. Can I help translate?

Thank you! Please continue here.


Read all 9 reviews

Contributors & Developers

“Redirect URL to Post” is open source software. The following people have contributed to this plugin.


“Redirect URL to Post” has been translated into 1 locale. Thank you to the translators for their contributions.

Translate “Redirect URL to Post” into your language.

Interested in development?

Browse the code, check out the SVN repository, or subscribe to the development log by RSS.




  • New parameters comment_count, comment_count_min (>=) and comment_count_max (<=) to filter by comment count. The value is always an integer. comment_count also takes negative values, which means “not”. Requires WordPress 4.9+.


  • Whitelisted more tracking parameters for Google and Matomo Analytics.



  • Fixed values of parameter “cat” getting lost.
  • Fixed incorrect inclusion of posts outside of “count” when using “bias”.



  • Button parameter ‘params’ now formatted as: “key1=value1|key2=value2| …” (Old format will continue working.)



  • New parameter ‘bias’, to be used together with ‘?redirect_to=random’ and ‘count’. The value of this parameter is a percentage that determines how much the posts determined by ‘count’ will be preferred over the rest. Example: -> The most recent 10 posts will be preferred with an 80% probability. Can be used together with ‘offset’.


  • Support for PHP versions older than 5.6 will be dropped in near future.



  • New parameter “count” that can be used together with “random” to limit the pool of posts to the most recent (count has positive number) or first (count has negative number). Can be used together with “offset”.


  • Changed default for cache to 60 seconds (Override it with cache=0)
  • Random posts are now always determined by PHP, not the database



  • New parameter “offset” to retrieve the 2nd, 3rd, (integer > 3)th post. Default is 0 (i.e. 1st). For example “offset=1” means 2nd post. An offset too high will trigger the procedure for the case when no post was found.
  • New parameter “suppress_filters” . Default is 1 (on). Turn off (“suppress_filters=0”) when you use WPML so that WPML can filter by language.


  • fixed problem when latest post was not published

Older Versions

The complete changelog is available here.