• 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?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    Sounds like HTML tags are being filtered for some reason. Where is this code inserted?

    (BTW, your second method is missing href quotes: echo "<a href=\"$url\">Click here</a>";)

    Thread Starter jralston

    (@jralston)

    Corrected using quotes in second method, still not working.
    I inserted this code into a wordpress page. Using the plugin “Allow PHP in Posts and Pages” to allow the use of php. Maybe the plugin is causing it? Is there a better one? The source code is not showing the href code either.

    Thread Starter jralston

    (@jralston)

    Solution! I used a different php plugin and it worked fine! “Shortcode Exec PHP” plugin seems to do the trick. Thank you to everyone for your feedback!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘PHP echo href problem’ is closed to new replies.