How to dispay thumbnail of posts in RSS feeds?

Posted on February 26th, 2011

the_post_thumbnail()is a very useful function which displays the post thumbnail image. Let us have a look on how to display thumbnail image in RSS using this function. It is pretty easy..
Add the below code in function.php.

function diw_post_thumbnail_feeds($content) {

global $post;

if(has_post_thumbnail($post->ID)) {

$content = ‘<div>’ . get_the_post_thumbnail($post->ID) . ‘</div>’ . $content;

}

return $content;

}

add_filter(‘the_excerpt_rss’, ‘diw_post_thumbnail_feeds’);

add_filter(‘the_content_feed’, ‘diw_post_thumbnail_feeds’);