Search code examples
phpwordpressif-statementechohref

How to echo a wordpress value inside an 'echo'


I'm trying to do this:

<?php 
global $current_user;
get_currentuserinfo();
if ( is_user_logged_in() ) {
    echo '<span class="ciao">HELLO ' . $current_user->user_login . '</span>'; "\n"; 
    echo '<a href=" . wp_logout_url( home_url() ); . " title="Logout">Logout</a>';
}
else {
    echo '<a href=" . wp_login_url( get_permalink() ); . " title="Login">Login</a>';
}
?>

The problem is that href gives me back the empty value: wp_logout_url( home_url() );

When I use this WORDPRESS call outside the echo it works good, like this eg:

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

How can i write this ??


Solution

  • None of those was, but I appreciated. This works well:

    '<a href="'.wp_logout_url( home_url() ).'">text</a>