0

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

3

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

?>
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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