WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Need some help here. I've been working on a widget to display a list of featured posts (custom post type) and want to display the featured image for each post so I was using the_post_thumbnail call with a custom thumbnail size included as the parameter and for some strange reason, the call is removing some of the HTML that is in my echo'd string output from the widget.

Below is the line that I am calling:

echo '  <li>'. the_post_thumbnail('talent-featured-thumb') .'</li>';

This is the HTML that is rendered:

<img width="225" height="127" src="PlaceHolder.png" class="attachment-talent-featured-thumb wp-post-image" alt="3MGPlaceHolder" title="3MGPlaceHolder" />   <li></li>

Any help?

share|improve this question
up vote 3 down vote accepted

the_post_thumbnail(); function is not supposed to be echo-ed! get_the_post_thumbnail(); is meant for that. Refer to the linked WordPress Codex pages.

Try this instead:


    // Wraps post-thumbnail in li tags
    echo ' <li>' . get_the_post_thumbnail('talent-featured-thumb') . '</li>';

share|improve this answer
Thanks so much! That worked like a charm! – ClockwiseQ Jul 15 '12 at 15:36

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.