Introduction

The WordPress plugin Redirect URL to Post sends your visitors to your first, your last, the previous, the next, a random, or any other post.

It works invisibly in the background. All URLs (links) that contain certain parameters redirect to a post that is determined by these parameters. The result depends on the available posts at the time when the redirect happens. The latest post of user Jane Doe, for example, can be different today and tomorrow.

All other URLs are not affected.

You can use the resulting URL as a link, in a menu or button, or you can even send it around in a newsletter. When your visitors load this URL, they will immediately be redirected to a post in single-post view.

Parameters

There are three types of parameters. Only the first one is mandatory.

1. Determine the target: random, first, last, previous, next, …

The only mandatory parameter is redirect_to. This target parameter basically determines a sort order of all relevant posts. We redirect to the post that ends up on top of that ordered list.

2. Narrow down the scope of posts

Then you can add filter parameters in order to narrow down the scope of posts to a specific subsample.

Note: If you want to use this plugin with any other post type than the default WordPress posts, you need to use the post_type parameter. Example for WooCommerce.

3. Tracking, caching, default target, …

Lastly, we have other parameters that determine what will happen if no post was found, set the caching time or enable tracking with Google Analytics or Matomo.

Now add them all to your WordPress site’s URL

The URL is composed according to the following pattern:

[your WordPress site's URL]?redirect_to=[target]&[further_parameter]&[further_parameter]...

The order of the parameters doesn’t matter, but you have to make sure that you first use “?” and afterwards always “&” when you glue the pieces together.

If you anywhere need to use spaces, you write them as %20.

So you could end up with an URL like this:

https://www.example.com/?redirect_to=random&before=yesterday&after=last%20month&cache=600

Tip: Save the URL to your clipboard1 before you hit Enter because it will disappear.

Examples

You can get some inspiration about what is possible on the page with redirect examples.

Show 1 footnote
  1. ctrl/cmd-a, ctrl/cmd-c

How do you rate this article?