Use Safely Redirect URLs in WordPress

In this tutorial, I will explain how to use safely redirect URLs in WordPress. The wp_safe_redirect() function does not exit automatically, if you are using this function in your code, then you should always used the exit(). See the below example:

Use Safely Redirect URLs in WordPress

You can use the below code in your theme’s files & template files to redirect to any custom URLS.

Description:

1) $location is a string and required parameter, it would be the URLS where page redirects.

2) $status is an integer and optional parameter, it would be the status code like 301 or 302. If you have not used this parameter, then the default value is 302.

wp_safe_redirect Example

Do you like & share this article with your friends, and don’t forget to follow us on Facebook and Twitter to learn cool WordPress tutorials.

If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.

Recommended Posts:


Prem Tiwari

An engineer by profession and a passionate blogger by heart. Founder of FreeWebMentor.com (A Programming blog for beginners), Tech Speaker at various forums. A part from this he is an open source enthusiast, WordPress Lover, Blogger, SEO, and Growth Strategic.

Article Tags: , , , , , , , ,