logout_url = wp_logout_url( $custom_login_url);
echo "<a class='handler-login-link logout' href='{$logout_url}'>".__("Logout","pixel_framework")."</a>";

I have created a custom logout link that is supposed to redirect users to a custom login page (within the same domain).

Logout is working fine, but the redirection is not working at all. After logging out redirected to the default wp-login page.

I tried to inspect HTML behind the link it is like this:

  • 1
    That's wrong. The logout URL should be https://example.com/wp-login.php?action=logout&_wpnonce=12345&redirect_to= etc. (and the redirect-to URL urlencoded). i.e. it should use the login page to log out. Unless you have a different logout handler, and a logout_url filter from one of your plugins? I'd guess that logout handler doesn't support the redirect.
    – Rup
    Commented Apr 6, 2021 at 22:22

1 Answer 1


Use this logout link <li class="signOut"><a href="<?php echo wp_logout_url(); ?>" title="Logout">Logout</a></li>

And add below code in your functions.php file to redirect the user to the page you want:

add_action( 'wp_logout', 'auto_redirect_user_after_logout');
function auto_redirect_user_after_logout(){
  wp_redirect( 'https://example.com/haendler-login/' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.