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.