How to add WordPress featured image to RSS item

In my Ricard Torres Blog I use the featured image in my theme to show that image at the beginning of each post.

The problem is, that image is not included in the RSS feed because it's not part of the post content. So RSS subscribers or Mailchimp subscribers won't see that image.

It can be solved by adding this straightforward snippet as a plugin or just copying it to your theme's functions.php file.


<?php /* Plugin Name: Add Featured Image to RSS Item Plugin URI: * Description: It adds the post featured image at the beginning of the post in the RSS feed items. * Version: 1.0 * Author: quicoto * Author URI: */ function add_featured_image_to_RSS ($content) { global $post; if ( has_post_thumbnail( $post->ID ) ){ $content = get_the_post_thumbnail( $post->ID, 'full' ) . $content; } return $content; } add_filter('the_content_feed', 'add_featured_image_to_RSS');
Code language: HTML, XML (xml)

About Ricard Torres

Senior Front-end Software Engineer at Netcentric, from Barcelona, Haidong Gumdo Instructor (korean martial art of the sword), street photographer, travel lover, TV addict, Boston Red Sox fan, and privacy advocate.

@ricard_dev @ricard_dev

📝 Blog 🎙 Podcast

Leave a Reply

Add <code> Some Code </code> if you need to.