
Especially in the case of a multi-author blog, it can be really useful to include a logout link on your theme. In this recipe, I’ll show you how to do this easily. Only suitable for WordPress 2.7.

Especially in the case of a multi-author blog, it can be really useful to include a logout link on your theme. In this recipe, I’ll show you how to do this easily. Only suitable for WordPress 2.7.
To create a "Logout" link on your WordPress blog, simply paste the following code on your theme:
<a href="<?php echo wp_logout_url(); ?>">Logout</a>
Please note that this will work with WordPress 2.7+ only. If you haven't switched to WP 2.7 yet, the following code will do (almost) the same job:
<a href="/wp-login.php?action=logout">logout</a>
8 Responses
Effectivement, j’avais remarqué qu’avec la nouvelle version de WordPress, la 2.7, la partie administration est d’autant plus sécurisée donc il s’est rajouté un wpnonce= à la fin du lien logout
Now, will that link only show up when you are logged in?
@Alison:
To make sure the link only show up when you’re logged in, proceed that way:
<?php if (is_user_logged_in()){
// the link goes here
} ?>
I have a question, wp_logout_url() will work with WordPress 2.7+ only, prior to WP 2.7 use logout. How to make them compatible with any version? can we make conditional statement?
Hello JB,
is it possibile to use the function and to apply a personalized anchor text to that?
Very helpful tip for those who are not having any meta widgets active or wish to have a handy logout link at the bottom on the footer or so :p
Trackbacks: