I have a WordPress site with “Sign In”option right side top: http://www.chicago-plastic-surgeons.com/

I want that when login in my WordPress site the then display a “Log Out” option only and “Sign In” would be disappeared like this: http://www.chicago-plastic-surgeons.com/events/

This is my code:

<div class="fix floatleft sign_in">
<a href="http://www.chicago-plastic-surgeons.com/wp-login.php">Sign In</a>
<a href="http://www.chicago-plastic-surgeons.com/wp-login.php?action=logout&  amp;redirect_to=http%3A%2F%2Fwww.chicago-plastic-surgeons.com&amp;_wpnonce=6049e0b736">Log out</a>

How could I fix it? Thank you.

N.B. Recently I have changed my site home page. So, I have already created and customized wp-login.php file in WordPress directory. I just want to use link form there which I mentioned in my code.

1 Answer 1


It's relatively simple to achieve that, you need to use the is_user_logged_in() function, as follows:

<div class="fix floatleft sign_in">
    <?php if(is_user_logged_in()) : ?>
        <a href="http://www.chicago-plastic-surgeons.com/wp-login.php?action=logout&amp;redirect_to=http%3A%2F%2Fwww.chicago-plastic-surgeons.com&amp;_wpnonce=6049e0b736">Log out</a>
    <?php else : ?>
        <a href="http://www.chicago-plastic-surgeons.com/wp-login.php">Sign In</a>
    <?php endif; ?>

The code asks whether the current user is logged in, and if they are show the log out button, if they're not logged in, it will show the log in button.

You can find out more information about the is_user_logged_in function on the WordPress Codex.

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.