How to add the Featured Image to WordPress RSS Feed

Problem:

By default, WordPress does not include the featured image in the RSS feed of your posts.

Solution:

Add this snippet of code to your functions.php or a mu-plugin. The below code uses the ‘large’ format image of the file saved as the featured image for the post.

function featuredIMGtoRSS($content) {
global $post;
if ( has_post_thumbnail( $post->ID ) ){
$content = '<div>' . get_the_post_thumbnail( $post->ID, 'large', array( 'style' => 'margin-bottom: 15px;' ) ) . '</div>' . $content;
}
return $content;
}
 
add_filter('the_excerpt_rss', 'featuredIMGtoRSS');
add_filter('the_content_feed', 'featuredIMGtoRSS');

Want to learn more about wordpress? Try this resource...

Digging into WordPress