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 before adding it to your RSS.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s