WordPress.org

Ready to get started?Download WordPress

Forums

PHP / echo / a href problem (6 posts)

  1. FionaGilbert
    Member
    Posted 4 years ago #

    Hi all,

    Having a problem getting my echo & a href link working. The code below just gives me a white page when I upload.

    I think I am doing some syntax wrong with the echo:
    http://paste-it.net/public/xdc246f/

    But I don't know what I'm doing wrong. Can you help?

    Thanks,
    Fiona

  2. codenextdoor
    Member
    Posted 4 years ago #

    Fiona,
    Try using single quotes to enclose what's being echoed and double for the href - like this:
    echo '<li><a href="<? the_permalink() ?>">'.$title.'</a></li>';

  3. FionaGilbert
    Member
    Posted 4 years ago #

    Thanks for that.

    That creates the link but not the permalink. It shows as 'http://domain.com/<? the_permalink() ?>'

    Any suggestions?

    Thank you

  4. esmi
    Forum Moderator
    Posted 4 years ago #

    Try:

    echo '<li><a href="' . get_the_permalink() . '"' . $title. '"</a></li>";

  5. FionaGilbert
    Member
    Posted 4 years ago #

    Hi esmi,

    Get a white screen with your code. Strange. Can't figure out what might me going amiss here.

    Any further suggestions greatly appreciated.

    Thanks

  6. FionaGilbert
    Member
    Posted 4 years ago #

    Hmmmmm,

    The only way I have got this to work is by wrapping the 'a href' around the query like so:

    http://paste-it.net/public/a8b45b2/

    Not sure if this is semantically correct but it works. Is this acceptable?

    Thanks

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.