Examples of WordPress Redirects to Posts

On this page you find examples how to use the parameters of the free WordPress plugin Redirect URL to Post for particular applications. Replace www.example.com with your own domain.

Redirect to a random post

Simple redirection to a random post

www.example.com?redirect_to=random

Random of another post type

Redirect to a random WooCommerce product:

www.example.com?redirect_to=random&post_type=product

Random of a subsample

Redirect to a random post among the latest 5 posts:

www.example.com?redirect_to=random&count=5

Redirect to a random post among the latest 5 posts, shifted by 2 posts (that means a random from the posts number 3 to 7, counting from the latest):

www.example.com?redirect_to=random&count=5&offset=2

Redirect to a random post among the oldest (first) 5 posts:

www.example.com?redirect_to=random&count=-5

Random with a bias

Redirect to a random post. Prioritize one of the latest 20 posts with a probability of 80% and consider the rest with a probability of 20%.

www.example.com?redirect_to=random&count=20%bias=80

Additional filter: time frame

Redirect to a random post that is older than 1 month but not older than 6 months:

www.example.com/?redirect_to=random&before=1%20month%20ago&after=6%20month%20ago

Additional filter: category

Redirect to a random post that has the category with the IDs 2 or 3:

www.example.com/?redirect_to=random&cat=2,3

Redirect to a random post that has not the category with the ID 2:

www.example.com/?redirect_to=random&cat=-2

Additional filter: comment count

Redirect to a random post that has no comments:

www.example.com/?redirect_to=random&comment_count=0

Redirect to a random post that has at least one comment:

www.example.com/?redirect_to=random&comment_count=-0

or:

www.example.com/?redirect_to=random&comment_count_min=1

Redirect to a random post with at least 3 comments:

www.example.com/?redirect_to=random&comment_count_min=3

Redirect to a random post with at most 10 comments:

www.example.com/?redirect_to=random&comment_count_max=10

Redirect to a random post that does not have 5 comments:

www.example.com/?redirect_to=random&comment_count=-5

Prefer Sticky Posts

Redirect to a random post, prefer one of your 5 sticky posts with a probability of 90%:

www.example.com/?redirect_to=random&ignore_sticky_posts=0&count=5&bias=90

Redirect to the first or the latest post

Redirect to the latest post:

www.example.com/?redirect_to=latest

Redirect to the first (oldest) post:

www.example.com/?redirect_to=first

Additional filter: tag

Redirect to the latest post with the tag ID 20.

www.example.com/?redirect_to=latest&tag_id=20

Additional filter: category

Redirect to the latest post with the category that has the ID 7:

www.example.com/?redirect_to=latest&cat=7

Additional filter: exclude posts

Redirect to the latest post, excluding posts with the IDs 5 and 13.

www.example.com/?redirect_to=latest&exclude=5,13

Additional filter: search string

Redirect to the first post that contains the search sting “hello”:

www.example.com/?redirect_to=first&s=hello

Additional filter: time frame

Redirect to the latest post that is older than 1 week:

www.example.com/?redirect_to=latest&before=1%20week%20ago

Redirect to the oldest post after yesterday:

www.example.com/?redirect_to=first&after=yesterday

Additional filter: author

Redirect to the latest post of the author with the ID 200:

www.example.com/?redirect_to=latest&author=200

Custom Redirects

Redirect to the post with the highest comment count:

www.example.com/?redirect_to=custom&orderby=comment_count

Redirect to the post with the lowest comment count:

www.example.com/?redirect_to=custom&orderby=comment_count&order=asc

Redirect to the post that comes first in alphabetical order (by its title):

www.example.com/?redirect_to=custom&orderby=title&order=asc

Default Redirects

Redirect to the latest post with the tag ID 23 and, if nothing was found, go to the post with the ID 34.

www.example.com/?redirect_to=latest&tag_id=23&default_redirect_to=34

Tracking of Redirects

Redirect to a random post and track the visit (Matomo):

www.example.com/?redirect_to=random&pk_campaign=random_link

Redirect to a random post and track the visit (Google):

www.example.com/?redirect_to=random&utm_campaign=random_link

Caching

Redirect to a random post with a caching time of 20 minutes (for all applicable posts – the random is picked out of the cache):

www.example.com/?redirect_to=random&cache=20

How do you rate this article?

Previous

Redirect Button