Post Pic

WordPress hack: Display post thumbnail in your RSS feed

Introduced in WordPress 2.9, get_the_post_thumbnail() allow you to display a thumbnail in your posts. But what about displaying post thumbnails in RSS feeds? Just read this recipe to know how to do.

Simply paste the following code in your functions.php file. The post thumbnail should be visible once you saved the file.

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

Thanks to Jeff Starr for this great tip!

One Response

Oct 30 2011 14:12

Hi i tried this hack but it gives error Fatal error: Call to undefined function add_filter() in wp-includes/functions.php on line 33 . please help me to solve this porblem. thanx in advance.

Trackbacks:

Leave a Comment

* Name, Email, Comment are Required