How to Add Post Thumbnail to your WordPress RSS Feeds

Posted on May 16th, 2010 by in Tutorials | 14 Comments  
How to Add Post Thumbnail to your WordPress RSS Feeds

In our earlier tutorial, we showed you how you can add post thumbnails in WordPress. The sad truth is that even if you enable the post thumbnails, it will not show up in your RSS feeds. But we have a solution for that. In this article, we will show you how you can add post thumbnails to your WordPress RSS feeds with a simple function.

All you have to do is open your theme’s functions.php file and add the following code:

function rss_post_thumbnail($content) {
global $post;
if(has_post_thumbnail($post->ID)) {
$content = '<p>' . get_the_post_thumbnail($post->ID) .
'</p>' . get_the_content();
}
return $content;
}
add_filter('the_excerpt_rss', 'rss_post_thumbnail');
add_filter('the_content_feed', 'rss_post_thumbnail');

Feel free to style this however you like. Remember to activate WordPress post thumbnails using our main WordPress post thumbnail tutorial before adding it to your RSS.

Source: Dave Redfern

About

Editorial Staff at WPBeginner mainly Syed and David.

Post comment as twitter logo facebook logo
Sort: Newest | Oldest

10x .. it's work perfectly :D

is this working for RSS reader wordpress widget...?? i looking for way to insert thumbnails image in rss widget..anyone..?

laksh 5 pts

Hi i tried this 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.

AndyiBM 5 pts

This works great, except that when there is a thumbnail present, the feed always repeats the post title within the content text (or excerpt text, as I'm using), which looks a little redundant. For posts without a thumbnail, the title is not repeated. Is there any way of removing this extra title text? It has no surrounding tags, so I can't hide it using CSS.

Is there anyway to align post thumbnails to the left of the entry in RSS feed?

Yes, add styling to it. Change the Paragraph tag into a Div and tell it to float left with some margin.

I think it's better if you change code:

$content=''.get_the_post_thumbnail($post->ID).''.$content;

to maintain the original content.

so what would the final code - all of it - look like?
Non-coder who wants a thumbnail in her blog feed.

The code in the article is the final code that you need... ofcourse if your theme doesn't have thumbnail enabled, then you will need more.

How would you make the post thumbnail link from RSS to the post?

I don't get along with PHP, any help is appreciated :)

You would modify the function a little bit. Add this php code in the link tag: the_permalink($post->ID)

This is really something! I would love to add something like this to Inside the Webb, I'll have to mess around with some code and see what I can do.

Tweets about us: