Logout button in menu without “wp” in links

You can use wp_logout_url() function for logout link. It will automatically add nonce to the url. Try this code: add_action(‘template_redirect’, function() { if (empty($_SERVER[‘REQUEST_URI’])) return; $uri = $_SERVER[‘REQUEST_URI’]; if (preg_match(‘#^/log-out/?$#’, $uri, $matches) === 1) { $logout_url = str_replace(‘&’, ‘&’, wp_logout_url()); wp_safe_redirect($logout_url); die; } }); If you do not want to use wp_logout_url(), then try to … Read more

WordPress Logout Redirect Follow up

It looks like you’re addressing me 😉 If you want to modify this code snippet: add_action( ‘wp_logout’,’go_home’ ); function go_home(){ wp_redirect( home_url() ); exit(); } you can replace the home_url() part with your custom page URL: ‘http://example.com/landingpage/’ but I wouldn’t recommend hardcoding the landing page, if it’s an internal page. You can try to construct … Read more