A Better Way for Users to Logout

Posted on April 15th, 2011

The old way of displaying a “Logout” link for your users looks like this:

<a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout">Logout</a>

Since WordPress 2.7, we can simplify this hodgepodge with a sleeker, cleaner, built-in template tag:

<a href="<?php echo wp_logout_url(); ?>">Logout</a>

Tags: , ,