Skip to content

Instantly share code, notes, and snippets.

@djm56
Last active May 13, 2017 06:56
Show Gist options
  • Save djm56/17db2821f14b3482fbbee36fd0bb3b7f to your computer and use it in GitHub Desktop.
Save djm56/17db2821f14b3482fbbee36fd0bb3b7f to your computer and use it in GitHub Desktop.
Simple Login and Logoff Link for WordPress
<?php
/*
*
* This checks if user is logged in
* If Logged in display logout link else display login link
* Also note the redirects to the login page and the home page.
*
*/
<?php if (is_user_logged_in()) : ?>
<a href="<?php echo wp_logout_url(site_url( '/login/ ' )); ?>">Logout</a>
<?php else : ?>
<a href="<?php echo wp_login_url(home_url()); ?>">Login</a>
<?php endif;?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment