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.

RANDOM REDIRECT METHOD

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

PLUGIN REQUIRED TO SET UP REDIRECTION

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.

JAVA SCRIPT CODE REQUIRED TO SET UP REDIRECTION

<script language="javascript" type="text/javascript">
var timeOut;
function reset() {
window.clearTimeout(timeOut);
timeOut = window.setTimeout( "redir()" , 10000 );
}
function redir() {
window.location = "https://www.your-website.com/";
}
window.onload = function() { setTimeout("redir()" , 10000 ) };
window.onmousemove = reset;
window.onkeypress = reset;
</script>

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

HOW TO SET UP AND WHERE TO PUT THE CODE

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

http://www.example.com/?redirect_to=latest – redirects to the latest post

http://www.example.com/?redirect_to=random&pk_campaign=random – redirects to a random post and tracks the visit

http://www.example.com/?redirect_to=random&after=1%20month%20ago – redirects to a random post among the posts that are not older than 1 month

http://www.example.com/?redirect_to=latest&exclude=4,7 – redirects to the latest post, excluding the posts with the IDs 4 and 7

http://www.example.com/?redirect_to=latest&offset=1 – redirects to the second latest post

http://www.example.com/?redirect_to=custom&orderby=comment_count&order=DESC – redirects to the post with the most comments

http://www.example.com/?redirect_to=latest&s=iaido&default_redirect_to=12&cache=200 – 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
    Share

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 *

*

code