We ♥︎ honesty! We may earn a commission through affiliate links on this page at no extra cost to you.

How to Set Logout Redirect to Homepage in WordPress: Easy Guide

Are you looking for an easy guide on how to set a logout redirect to the homepage or any other URL in the WordPress site? Yes, here I will show you the best guide for this. Using this step by step WordPress logout redirection guide, you can easily set a WordPress site redirect to the homepage without any plugin.

We all know that the default behavior of the WordPress login redirect is to the wp-admin dashboard and logout redirect to the wp-login means WordPress login page.

Logout Redirect

But you may need to change this default behavior. The default redirection is not the best practice if you build a business site or an online store.

Besides, there are lots of reasons for changing this redirect value. You can change it for WordPress security purposes or not showing default login & logout redirect to the backend to your customers. So both redirects are not ideal especially if the user can access the backend area after logout.

How to Set Logout Redirect to Homepage

You can set this redirect using two ways one is a plugin another is a manual. I always prefer to use a manual way which is mainly using code snippet instead of using a plugin. There are lots of reasons why you should avoid install so many plugins on your WordPress site. The best reasons are WordPress security and speed performance.

logout redirect code

However back to the step-by-step guide, first of all, login to your WordPress site and create a child theme.

Note that, before using any custom code on your site especially for the funcation.php file, you should backup the whole site or use a child theme.

 If you do not know how to create a WordPress child theme of any theme, you can check my other guide on how to create a WordPress child theme.

After creating a child theme, go to the funcation.php of your child theme and paste the following codes.

add_action('wp_logout','ps_redirect_after_logout');
function ps_redirect_after_logout(){
         wp_redirect( 'Your redirect URL here' );
         exit();
}

Now finally click on the update file button. You are done.

Using a WordPress plugin

There are many WordPress plugins to enable login and logout redirection. But I will recommend using Peter’s Login Redirect which is the best plugin for setting user-specific login-logout redirection.

Firstly install and activate this plugin on your WordPress site then go to setting>login/logout redirects.

logout redirect plugin guide

Now go to the ‘All other users’ option and enter the logout URL on the logout URL field. You do not need to enter the site URL on the URL field. So keep it blank.

Then finally click on the update button. Now you are done.

Note: With this plugin, you can set a logout redirection with different roles, levels, and users. You can check it yourself. The activation process is super easy. Here I have guided you only the easy way which are for all users.

Now you can check is it working or not on your WordPress site.

If you get any issues while implementing code on your site or using the plugin, please let me know. I will try to guide you from my best.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.