Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
add comment

1 Answer

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:

<?php

    // 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
add comment

Your Answer

 
discard

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.