Skip to main content

Add Featured Image to WordPress RSS Feed

In our earlier tutorial, we have shown you how to add featured image or thumbnail to WordPress post. But the featured image would not be automatically displayed in the RSS feed. A filter need to be added to display featured image in RSS feed. In this article, we’ll provide the simple way to add featured image to WordPress RSS feed. Using add_filter() with a simple function, you can easily include post thumbnail in RSS feeds.
Open the theme’s function.php file and add the following code in this file.

// display featured post thumbnails in WordPress rss feeds
function add_post_thumbnail_in_rss_feeds($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', 'add_post_thumbnail_in_rss_feeds');
add_filter('the_content_feed', 'add_post_thumbnail_in_rss_feeds');

Post Thumbnail Size

You can display your desire size of the featured image by using the second parameter of get_the_post_thumbnail() function. Specify the post thumbnail width and height as an array.

get_the_post_thumbnail($post->ID, array(650,350))

Are you want to get implementation help, or modify or extend the functionality of this script? Submit paid service request