Send people to your home page, or any page you choose, after they log out instead of the "You are now logged out" screen.
add_filter( 'logout_redirect', function ( string $redirect_to, string $requested, $user ): string {
// Respect a redirect set by a plugin or a logout link with ?redirect_to=.
if ( '' !== $requested ) {
return $redirect_to;
}
return home_url( '/' );
}, 10, 3 );
Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.
After logging out, WordPress shows the login form with a “You are now logged out” message. For customers and members it’s more natural to land back on your site. This snippet redirects them to the home page.
The logout_redirect filter sets where WordPress sends people after logout. If the logout link already asked for a page with ?redirect_to=, the snippet leaves it alone. Otherwise it returns your home page.
home_url( '/' ) to any page, for example home_url( '/goodbye/' ).Log in, then click Log Out. You should land on your home page.