Add Featured Image To RSS Feed In WordPress
In these articles, We’ll show you how to add featured image to RSS feed in WordPress from all your posts. Because WordPress does not include featured image in rss feeds even after you enable the post thumbnails support. But don’t worry here we share a piece of code that you need to add in your function file. These tricks update globally on your WordPress RSS Feed URL. And It will effect on your Feedburner or any other feed management provider.
Add Featured Image To RSS Feed
Right now, few plugins are available that can quickly help you achieve this feature. For example, Featured Images in RSS for Mailchimp & Other Email, Featured Images in RSS, Send Images to RSS. But we strongly believe that install less plugin as much as possible. So we have avoid to install these plugin. Directly paste the following code into your theme’s functions.php
file.
/**
* Add feature image in RSS feed
*/
function wcs_post_thumbnails_in_feeds( $content ) {
global $post;
if( has_post_thumbnail( $post->ID ) ) {
$content = '<p>' . get_the_post_thumbnail( $post->ID, 'large', array( 'style' => 'max-width: 100%; height: auto;' ) ) . '</p>' . $content;
}
return $content;
}
add_filter( 'the_excerpt_rss', 'wcs_post_thumbnails_in_feeds' );
add_filter( 'the_content_feed', 'wcs_post_thumbnails_in_feeds' );
Here you can manage the styles of features image. Moreover, you can set the image size large
, medium
, thumbnail
, thumb
, and post-thumbnail
. Above example, we set large size of the image. Later we set feature image width maximum 100% using style attribute.
Another Solutions
If you are not a technical person, then you can do the same thing from your WordPress dashboard. You need to install a Code Snippet plugin. Again we repeat you try to install less plugin. But Code Snippets is an easy and straightforward way to run PHP code snippets on your site.
Click on add new button. Paste it above code into code section. Next you have to select “Only run on site front-end” option. Hurry all done!
That’s all you need to do. You can see thumbnails in your feeds! You can see our feed URL on here. If this tutorial helpful you to show featured image in your WordPress RSS, we would love to hear in the comments below! You can explore here other WordPress related posts.
If you like our article, please consider buying a coffee for us.
Thanks for your support!
Buy me a coffee!
Working perfect!
Thank you