Home  »  CodeGuidesLibrariesProgrammingSnippetsTechnology   »   Logout to Home Page in WordPress

Logout to Home Page in WordPress

Posted: May 11, 2022 | by Site Host

Use this code snippet to logout to home page in WordPress.

The WordPress logout link:

<a href="<?php echo wp_logout_url( home_url() ); ?>">Logout</a>

WordPress logout to home page in functions.php theme file:

function redirect_home_after_logout(){
   wp_safe_redirect( home_url() );
   exit;
}
add_action( 'wp_logout', 'redirect_home_after_logout' );

Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.

Share it!

See also  How to Use jQuery to Disable and Enable an HTML Input