How to Add Post Thumbnail to RSS Feed in WordPress

How to Add Post Thumbnail to RSS Feed in WordPress

In this tutorial, I will show you how to add post thumbnail to rss feed in WordPress using very simple few line of code without using any plugin. This code working fine for add WordPress featured image RSS feed address. This will take just few minute.

First we need to add some code to your website. Open your website theme function.php file and put below code into function.php file and save.

function featuredtoRSS($content)
     global $post;
     if ( has_post_thumbnail( $post->ID ) ){
         $content = '
' . get_the_post_thumbnail( $post->ID, 'thumbnail', array( 'style' => 'margin-bottom: 15px;' ) ) . '
' . $content;
     return $content;
 add_filter('the_excerpt_rss', 'featuredtoRSS');
 add_filter('the_content_feed', 'featuredtoRSS');

In get_the_post_thumbnail() function you can also use medium and large instant of thumbnail. according to your requirement of image size. for example:
$content = get_the_post_thumbnail( $post->ID, ‘large’)

adding images to rss feed, wordpress import rss feed with featured image, wordpress rss feed plugin with image, rss feed with images example, wordpress rss feed image missing, rss feed to post wordpress plugin, wordpress rss image tag, wordpress rss thumbnail image

Mukesh Jakhar - PHP Web Developer
Mukesh Jakhar

This is Mukesh Jakhar. I’m a professional web developer with 3+ years experience. I am always ready for freelance work and i am writing blogs in my free time. I love to learn new technologies and share with others.

I founded PHPKIDA in September 2015. The focus of this website to provide web development tutorials of PHP, WordPress, CodeIgniter, Jquery, MySQL, HMTL, CSS etc and sharing solution to problems which i already solved.

Sign up for weekly update

Milkshake is almost ready. If you're interested in testing it out, then sign up below to get exclusive access.