Redirect

How can I make a redirect in WordPress?

Sometimes it’s good to be able to redirect people from one page to another page. As an example if you have a Forum, if you have a custom 404 page and so on...

Chapter 1: Add an instant redirect
Chapter 2: Add a redirect with time-delay
Chapter 3: If the codes don't work (depends on the theme)

Chapter 1: Add an instant redirect

1. To include an instant redirect Copy & paste the following code to the page you want the redirect to happen

<script type="text/javascript">
parent.location.replace('url of the external site');
</script>

2. Replace "url of the external site" with the url of the page or site you want people to be redirected to and that's it.

Chapter 2: Add a redirect with time-delay

1. To include a redirect with some time-delay Copy & paste the following code to the page you want the redirect to happen

<script type="text/javascript">
var url ='url of the page';
var delay = 4;
var d = delay * 1000;window.setTimeout ('parent.location.replace(url)', d);
</script>

Replace "url of the page" with the url of the page or site you want people to be redirected to
The number 4 in the code stands for the delay of time (in seconds) before people get redirected, you can change it to fit your case

Chapter 3: If the codes don't work (depends on the theme)

Depending on the theme you're using the codes I posted in Chapter 1 and Chapter 2 of this post don't work. In that case you could use a Plugin called Redirection.

This FAQ is also discussed in my WPFAQ.org E-Book (sample)

© WPFAQ.org - Tutorials, Tips & Tricks is made with WordPress and for WordPress.
It's an EBookStoretoday.com company. It’s presented by Cédric Giger and hosted by HostGator.com
Thank you for visiting and supporting my website,
- Cédric -

Now share it…

Share

Comments are closed.