How to redirect to another page in WordPress

Must Read : How to redirect to another page in WordPress

A page can be redirected to a new page or URL. There are different methods to achieve this. In this blog post we will deal with all these methods in details.

Use of these methods depends upon different  use cases. Sometimes HTML redirect work perfectly, in some cases JavaScript or PHP.

There is a WordPress function which can also be used and I think it is best to use WordPress function.

Here are different methods for redirect

HTML Method

In this method we will use meta redirect. Add following code in head section(between <head> and </head>) of your theme header.php .

<meta http-equiv="refresh" content="1; url=http://example.com/" />

Where

http://wearecoders.net is the url where we want to redirect.

JavaScript Method

window.location object can be used to redirect current page URL  to new URL using following code block. Write this block in head area(between <head> and </head>) of header.php

    window.location.href = "http://wearecoders.net"
(Visited 33 times, 1 visits today)

Leave a Comment.