“Are you sure you want to logout” Error? Here’s the Fix.

Have you ever gotten that annoying message “You are attempting to log out of example.com. Please try again.” while trying to logout of your site?

Here’s what the codex has to say about that:

The Template Tag wp_logout_url was added in Version 2.7 to provide a nonced URL for logout purposes. If a theme uses a construct such as /wp-login.php?action=logout to offer the user a logout link that code should be updated to use the wp_logout_url. A good example of the usage of wp_logout_url can be seen in the WordPress Default and Classic themes comments.php and comments-popup.php Templates.

The Fix:

Replace your old logout tag with something similar to this:

<a href="https://wpmudev.com/blog/daily-tip-are-you-sure-you-want-to-logout-error-heres-the-fix/<?php echo wp_logout_url(); ?>" title="Logout">Logout</a>