WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On our website we have a "Join" button in the top right corner and a log in / log out link using <?php wp_loginout(); ?> . Instead of having the log in / log out link we would like to have it display in a button. It should ready "Login" when something like if ( is_user_logged_in() ) is false and "Log Out" when it's true.

The Code for the Join Button is:

<a href="www.google.com" class="join-button">Join</a>

so the code for the Log in / log out button should have the same .join-button class.

Style for .join-button:

.join-button {
-moz-box-shadow:inset 0px 1px 0px 0px #f5840c;
-webkit-box-shadow:inset 0px 1px 0px 0px #f5840c;
box-shadow:inset 0px 1px 0px 0px #f5840c;
border:1px solid #f5840c;
padding: 1px 4px;
text-shadow:1px 1px 0px #f5840c;

Could someone please help me write the code to achieve this task?

share|improve this question

here is a very simple function that should do it:

function loginout_button_wpa89153($echo = true){
    if (is_user_logged_in()){
        $url = wp_logout_url(get_permalink());
        $anchor = "Logout";
        $url = wp_login_url(get_permalink());
        $anchor = "Login";
    $button = '<a href="'.$url.'" class="join-button">'.$anchor.'</a>';
    if ($echo)
        echo $button;
        return $button;
share|improve this answer
Thanks for your work with that, however, it's not displaying anything on my end. – Patrick Mar 3 '13 at 17:17
did you call it? – Bainternet Mar 3 '13 at 18:20
@Patrick instead of <?php wp_loginout(); ?> replace it with <?php loginout_button_wpa89153(); ?> – Rajeev Vyas Apr 2 '14 at 7:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.