How to Redirect Visitors to a Random Post after Specific Time Gap in WordPress

Have you ever thought of “How to Redirect Visitors to a Random Post after Specific Time Gap in WordPress” and keep engaging your visitors to visit more pages by redirecting them to a random post after a time gap? If not, then do this right now by following the method explained below to increase SEO value of your site.

There are n-number of plugins which will help you in redirecting to a random post in WordPress self hosting blogs. But, let me tell you honestly, there is hardly a single plugin which will do this unique feature where a wordpress blog is set to redirect to random post after a specific time gap set by the admin of the blog. I have been looking for a solution for months and came out with this trick and working perfectly the way I wanted it to be. This is combination of a plugin and a piece of java script code which are combined together to give the end result which is just superb.

Before you jump to start building up your redirect, just take a look at this demo site. The delay time is set approximately 15 minutes+. So, if you want to check it working, just note down the page you are in now and check back after 15 minutes and you will find yourself in another page.


I will cover this topi in these steps:

  • Plugin required to set up redirection
  • Java script code required to set up redirection
  • How to set up and where to put the code

So, let’s get started


You will required these plugins to set up redirection. All these plugins are available free in the wordpress plugin directory from where you can search, install and activate.

Just install these 3 plugins first and then proceed to next step. You can find the usage guide of these plugins in their respective website.


<script language="javascript" type="text/javascript">
var timeOut;
function reset() {
timeOut = window.setTimeout( "redir()" , 10000 );
function redir() {
window.location = "";
window.onload = function() { setTimeout("redir()" , 10000 ) };
window.onmousemove = reset;
window.onkeypress = reset;

Here the number 10000 shows the gap of 10 seconds. 1 second = 1000, so accordingly you can set your time.


1. For plugin “Redirect URL to Post” you will not find any settings option. You can use any of the option below to redirect.

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

2. For plugin “Simple 301 Redirects” go to settings from left sidebar wordpress Settings option and fill in details like it is showing the image below.

3. For plugin “Insert Headers and Footers” open the settings and paste the java script code in the header area like this.

Hope this was quite simple and you did it perfectly. If you still face any problem, you can write for the support in the comment box below.

Support Us By Sharing
  • 1

Author: Aliva Tripathy

Taking out time from a housewife life and contributing to AxiBook is a passion for me. I love doing this and gets mind filled with huge satisfaction with thoughtful feedbacks from you all. Do love caring for others and love sharing knowledge more than this.

1 thought on “How to Redirect Visitors to a Random Post after Specific Time Gap in WordPress

Leave a Reply

Your email address will not be published. Required fields are marked *