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?

1 Answer 1


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>';


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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