how to logout on button click in wordpress code example
Example 1: wordpress logout to home page
// on your theme -> functions.php -->
add_action('wp_logout','auto_redirect_after_logout');
function auto_redirect_after_logout(){
wp_safe_redirect( home_url() );
exit;
}
Example 2: wordpress logout
wp_logout()