WordPress.org

Support

Support » How-To and Troubleshooting » echo a link – help

echo a link – help

  • artfulalibi
    Member

    @artfulalibi

    Hello,

    Please forgive my basic PHP skills. I am writing a basic function, but for some reason I can’t get the links to come out right. Here is my code:

    function featuredStory() {
    $featuredPosts = new WP_Query();
    $featuredPosts->query('cat=9&showposts=5');
    while ($featuredPosts->have_posts()) : $featuredPosts->the_post();
    echo '<a href="' .the_permalink(). '" rel="bookmark">' .the_title(). '</a>';
    endwhile;
    }

    The resulting link doesn’t work. It shows up like this:

    http://siteurl/?p=9This is the first featured
    <a rel="bookmark" href=""/>

    Why is the anchor text showing up after, and with no closing a? I have tried reworking it, over and over. Arrg!

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘echo a link – help’ is closed to new replies.