Function or Plugin code to send featured image along with your RSS feed content

Here is the code if you would like to see your featured image inside your excerpt or content in RSS feeds.
Normally URL used to check your feeds is http://sitename/feed/ e.g. https://techobia.com/feed

Here is code which you can simply paste it inside your theme fucntions.php file or you can make it is an independent plugin.

// THIS INCLUDES THE THUMBNAIL IN OUR RSS FEED
function insertThumbnailRSS($content) {
global $post;
if ( has_post_thumbnail( $post->ID ) ){
$content = '' . get_the_post_thumbnail( $post->ID, 'thumbnail' ) . '' . $content;
}
return $content;
}

add_filter('the_excerpt_rss', 'insertThumbnailRSS');
add_filter('the_content_feed', 'insertThumbnailRSS');

After this you can see images in your RSS feed and here is tested snapshot for it.

1 Response

  1. Avatar oakley says:

    Thanks a lot for sharing!