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=randomRandom of another post type
Redirect to a random WooCommerce product:
www.example.com?redirect_to=random&post_type=productRandom of a subsample
Redirect to a random post among the latest 5 posts:
www.example.com?redirect_to=random&count=5Redirect 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=2Redirect to a random post among the oldest (first) 5 posts:
www.example.com?redirect_to=random&count=-5Random 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=80Random, not repeating posts
Redirect to a random post, going through all posts, then redirect to the page or post with the ID 222.
www.example.com?redirect_to=random&each_once=222Redirect to a random post, going through all posts, then start over again.
www.example.com?redirect_to=random&each_once=rewindRandom, using the time lock
Redirect to a random post, then keep redirecting to this post for one day (60*60*24=86400 seconds), then pick another random post that we haven’t seen yet. When all posts are done, start over again.
www.example.com?redirect_to=random&lock=86400&each_once=rewindAdditional 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%20agoAdditional filter: category
Redirect to a random post that has a category with the ID 2 or 3:
www.example.com/?redirect_to=random&cat=2,3Redirect to a random post that has not the category with the ID 2:
www.example.com/?redirect_to=random&cat=-2Additional filter: custom taxonomy
Note: In most cases, when filtering by a custom taxonomy, you are searching among a custom post type. In that case you will also need the post_type parameter. Otherwise we would search among ordinary posts.
Redirect to a random WooCommerce product that has a post category with the IDs 2 or 3:
www.example.com/?redirect_to=random&post_type=product&custom_taxonomy_slug=product_cat&custom_taxonomy_field=term_id&custom_taxonomy_term=2,3Redirect to a random WooCommerce product that has a product tag with the slug “sale”. When a user calls the link repeatedly, pick each item only once, then start over again:
www.example.com/?redirect_to=random&post_type=product&custom_taxonomy_slug=product_cat&custom_taxonomy_field=slug&custom_taxonomy_term=sale&each_once=rewindAdditional filter: comment count
Redirect to a random post that has no comments:
www.example.com/?redirect_to=random&comment_count=0Redirect to a random post that has at least one comment:
www.example.com/?redirect_to=random&comment_count=-0or:
www.example.com/?redirect_to=random&comment_count_min=1Redirect to a random post with at least 3 comments:
www.example.com/?redirect_to=random&comment_count_min=3Redirect to a random post with at most 10 comments:
www.example.com/?redirect_to=random&comment_count_max=10Redirect to a random post that does not have 5 comments:
www.example.com/?redirect_to=random&comment_count=-5Prefer 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=90Redirect to the first or the latest post
Redirect to the latest post:
www.example.com/?redirect_to=latestRedirect to the first (oldest) post:
www.example.com/?redirect_to=firstAdditional filter: tag
Redirect to the latest post with the tag ID 20.
www.example.com/?redirect_to=latest&tag_id=20Additional filter: category
Redirect to the latest post with the category that has the ID 7:
www.example.com/?redirect_to=latest&cat=7Additional filter: exclude posts
Redirect to the latest post, excluding posts with the IDs 5 and 13.
www.example.com/?redirect_to=latest&exclude=5,13Additional filter: search string
Redirect to the first post that contains the search sting “hello”:
www.example.com/?redirect_to=first&s=helloAdditional filter: time frame
Redirect to the latest post that is older than 1 week:
www.example.com/?redirect_to=latest&before=1%20week%20agoRedirect to the oldest post after yesterday:
www.example.com/?redirect_to=first&after=yesterdayAdditional filter: author
Redirect to the latest post of the author with the ID 200:
www.example.com/?redirect_to=latest&author=200Previous or Next
The following examples assume that we use the link of a particular post, product or page. Applying the examples on virtual pages like the front page or the posts page (where posts are listed) might lead to unexpected results (because they are often not ordered by a date).
Redirect to the previous post:
www.example.com/my-great-post/?redirect_to=prevRedirect to the post before the previous post:
www.example.com/mind-numbing-post/?redirect_to=prev&offset=1Redirect to the next product:
www.example.com/worst-shelf-warmer-ever/?redirect_to=nextCustom Redirects
Redirect to the post with the highest comment count:
www.example.com/?redirect_to=custom&orderby=comment_countRedirect to the post with the lowest comment count:
www.example.com/?redirect_to=custom&orderby=comment_count&order=ascRedirect to the post that comes first in alphabetical order (by its title):
www.example.com/?redirect_to=custom&orderby=title&order=ascDefault 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=34Tracking 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=20Debugging
Show the resulting link on the screen when you redirect to a random post before last month and after eight months ago, including information about caching.
www.example.com/?redirect_to=random&before=last%20month&after=8%20month%20ago&rutpdebugShow detailed information in the debug.log, without interrupting the redirections.
www.example.com/?redirect_to=random&verbose_debugButton
Display a button that redirects to a random item among a list of pages, specified by their IDs.
[redirect_to_post_button text="Go to a random page" redirect_to="random" params="post_type=page|include=1,2,4,35,34,35,892"]