Title: Problem with echo
Last modified: August 19, 2016

---

# Problem with echo

 *  Resolved [macoD](https://wordpress.org/support/users/macod/)
 * (@macod)
 * [15 years ago](https://wordpress.org/support/topic/problem-with-echo-1/)
 * I have problem with echo.
    This code:
 *     ```
       <?php
       if ( get_post_meta($post->ID, 'price', true) )
       {
        	echo '<a href="'.get_post_meta($post->ID, 'price', true).'">'.the_post_thumbnail('slider')."</a>";
       }
       else
       {
          echo the_post_thumbnail('slider');
       }
       ?>
       ```
   
 * generate :
    `<img width="730" height="280" src="http://localhost/wordpress/wp-
   content/uploads/2011/04/reel_1.jpg" class="attachment-slider wp-post-image" alt
   ="reel_1" title="reel_1" /><a href="http://localhost/wordpress/portfolios/project-
   1/"></a>`
 * but should:
    `<a href="http://localhost/wordpress/portfolios/project-1/"><img
   width="730" height="280" src="http://localhost/wordpress/wp-content/uploads/2011/
   04/reel_1.jpg" class="attachment-slider wp-post-image" alt="reel_1" title="reel_1"/
   ></a>`
 * Please help, thx.

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

 *  Moderator [Ipstenu (Mika Epstein)](https://wordpress.org/support/users/ipstenu/)
 * (@ipstenu)
 * 🏳️‍🌈 Advisor and Activist
 * [15 years ago](https://wordpress.org/support/topic/problem-with-echo-1/#post-2060292)
 * `echo '<a href="'.get_post_meta($post->ID, 'price', true).'">'.the_post_thumbnail('
   slider')."</a>";`
 * You seem to be mixing ‘ and ” in there. Try this:
 *     ```
       echo '<a href="'.get_post_meta($post->ID, 'price', true).'">'.the_post_thumbnail('slider').'</a>';
       ```
   
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [15 years ago](https://wordpress.org/support/topic/problem-with-echo-1/#post-2060294)
 * `the_post_thumbnail()` does not return the image code, as you would need for 
   your code snippet.
 * try:
 *     ```
       <?php
       if ( get_post_meta($post->ID, 'price', true) )
       {
        	echo '<a href="'.get_post_meta($post->ID, 'price', true).'">'; the_post_thumbnail('slider'); echo "</a>";
       }
       else
       {
          the_post_thumbnail('slider');
       }
       ?>
       ```
   
 *  Thread Starter [macoD](https://wordpress.org/support/users/macod/)
 * (@macod)
 * [15 years ago](https://wordpress.org/support/topic/problem-with-echo-1/#post-2060300)
 * Alchymyth,
    thank you, this works.

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

The topic ‘Problem with echo’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 3 participants
 * Last reply from: [macoD](https://wordpress.org/support/users/macod/)
 * Last activity: [15 years ago](https://wordpress.org/support/topic/problem-with-echo-1/#post-2060300)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
