Redirect URL to Post


This plugin provides an URL that takes you directly to a post in single-post view. The post is determined by the query parameter ?redirect_to= and optional others. The URL will redirect to the first of all matching posts according to the chosen order. You can, for example, redirect to your latest, oldest or a random post, or to your second latest, or the first post that is not older than two months.

You can simply enter the URL of your WordPress site into your browser and add ?redirect_to=… to the end. You can, of course, also use that URL in any link, in a menu, a button and so on. The plugin will recognize it and redirect the browser to the right post or page.

The plugin offers optional caching of database results.

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.

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 here.

Examples for URLs – redirects to the latest post – redirects to a random post and tracks the visit – 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.


  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.

plugin website


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 8 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 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.