search ]

Redirect to Homepage After Logout in WordPress

When a user logs out, WordPress by default sends them back to the login page (wp-login.php). In many cases it makes more sense to redirect them to the site homepage. Here is a snippet that does that:

add_action('wp_logout', function()
{
    wp_redirect(get_home_url());
    exit;
});

For more on redirects and SEO, see 301 Redirects and Their SEO Importance.

Join the Discussion
0 Comments  ]

Leave a Comment

To add code, use the buttons below. For instance, click the PHP button to insert PHP code within the shortcode. If you notice any typos, please let us know!

Savvy WordPress Development official logo