Title: echo a link &#8211; help
Last modified: August 19, 2016

---

# echo a link – help

 *  [artfulalibi](https://wordpress.org/support/users/artfulalibi/)
 * (@artfulalibi)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/echo-a-link-help/)
 * 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)

 *  [cutomthemedesign](https://wordpress.org/support/users/cutomthemedesign/)
 * (@cutomthemedesign)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/echo-a-link-help/#post-885296)
 * Hello,
 * Try something like this:
 *     ```
       echo '<a href="' .get_permalink(). '" rel="bookmark">' .the_title('', '', 0). '</a>';
       ```
   
 * Good Bye!
 *  Thread Starter [artfulalibi](https://wordpress.org/support/users/artfulalibi/)
 * (@artfulalibi)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/echo-a-link-help/#post-885344)
 * Thanks Custom! That worked. I guess the_title() requires those parameters in 
   order to parse correctly?
 *  [cutomthemedesign](https://wordpress.org/support/users/cutomthemedesign/)
 * (@cutomthemedesign)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/echo-a-link-help/#post-885393)
 * Yes the zero parameter will save the result instead of printing it. so this way
   it works when you add “echo” command to it.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘echo a link – help’ is closed to new replies.

## Tags

 * [featured](https://wordpress.org/support/topic-tag/featured/)
 * [format](https://wordpress.org/support/topic-tag/format/)
 * [function](https://wordpress.org/support/topic-tag/function/)
 * [link](https://wordpress.org/support/topic-tag/link/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [cutomthemedesign](https://wordpress.org/support/users/cutomthemedesign/)
 * Last activity: [17 years, 7 months ago](https://wordpress.org/support/topic/echo-a-link-help/#post-885393)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
