I am having a heck of time trying to echo a link. Here

I am having a heck of time trying to echo a link. Here is my code:

if ( ! is_user_logged_in() ) { // Display WordPress login form:
$args = array(
'form_id' => 'loginform-custom',
'label_username' => __( 'Username custom text' ),
'label_password' => __( 'Password custom text' ),
'label_remember' => __( 'Remember Me custom text' ),
'label_log_in' => __( 'Log In custom text' ),
'remember' => true
wp_login_form( $args );
wp_register('You must ', ' and login in order to post on this forum.');
echo '<a href="' . wp_lostpassword_url() . '">Lost Password</a>';
$url = wp_lostpassword_url('/');
echo "<a href=$url>Click here</a>";
} else { // If logged in:

echo " Welcome! You are logged in. | ";
wp_loginout( home_url() ); // Display "Log Out" link.

As you can see I’ve tried 2 ways of displaying the href and neither are working. I have tried many different ways and none are displaying the url as clickable. I can echo the correct url and the “Lost Password” words – but it’s not clickable. I cannot get the href part of it to work. It needs to be within the if/else statement. Suggestions please?

  • Alexander
    • DEV MAN’s Mascot

    Hi @julie77,

    I don’t see why that wouldn’t work.

    With the second method, some quotes would be nice around the URL. You can add these in by escaping them with a

    echo "<a href="$url">Click here</a>";

    What about the generated source? could you show what this code is giving when you view the source code after running it? Anything seem off there?

    Also, have you tried just doing a normal link to see if it’s clickable?


    Maybe something is filtering your HTML somehow.

    Best regards,

  • julie77
    • WPMU DEV Initiate

    Corrected the second method, but still not working. Source code is not showing the href code. Using the plugin “Allow PHP in Posts and Pages” to allow the use of php on a wordpress page. Maybe the plugin is causing it? Is there a better one? Looks like images are not being pulled through either.

    echo "<img src="http://photos.appleinsider.com/v9/images/wordmark.png" />";

    Normal, non-php links work fine.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.