In this tutorial, I’ll show you how easy it is to add a featured image from all your posts anywhere in your RSS feed. This tip works regardless of whether you’re using Feedburner or your default WordPress RSS feed address.
This is a great solution for when you are using your own RSS feed sources with WP RSS Aggregator.
Follow the steps below to add featured images to your RSS Feed in WordPress:
Step 1
We need to add some code to your website. We could do it by adding it directly to your theme’s functions.php file, but that is not the safest way to do things.
We recommend adding it via a child theme or by using the free Add Shortcodes Actions and Filters plugin. Once you have installed this plugin or found your child theme’s functions.php file, move on to step 2.
Step 2
Add the following code at the bottom of your child theme’s functions.php file (If you don’t know what you are doing, make sure to backup your functions.php file before editing it), or to the Add Shortcodes Actions and Filters plugin.
function featuredtoRSS($content) { global $post; if ( has_post_thumbnail( $post->ID ) ){ $content = '' . get_the_post_thumbnail( $post->ID, 'thumbnail', array( 'style' => 'float:left; margin:0 15px 15px 0;' ) ) . '' . $content; } return $content; } add_filter('the_excerpt_rss', 'featuredtoRSS'); add_filter('the_content_feed', 'featuredtoRSS');
Step 3
In the above code, we used medium for the thumbnail size. This will appear in our RSS feed as you can see below. You could change this to thumbnail or full if you prefer. Medium seems to work the best for all platforms.
NOTE: Some RSS feed management services like Feedburner may cache your feed which means you may need to wait for it to update before your featured image displays. You can Ping Feedburner so it updates immediately.
Featured Image via Plugin
If you want an even easier way of including a featured image in your feed items, you can use the Add Featured Image to RSS Feed plugin. It’s a simple plug-and-play solution. This plugin does one thing, and that thing is to add your posts’ featured image to the RSS feed. It specifies the ‘large’ image size.
27 Responses
This is great! Although, my image is added to the tag in the RSS feed. How can I get it into a separate tag (like “image” or whatever is best practice)?
“Description” was deleted in my original post. It should read:
my image is added to the “description” tag in the RSS feed…
Hi Luke,
You can add a custom node to the rss feed as explained in this link http://codex.wordpress.org/Plugin_API/Action_Reference/rss2_item
hmmmm… Can’t get this to work… Using Be Theme. Any ideas?
It was really troublesome and my RSS-to-Email campaigns look ugly and unprofessional. Finally, succeeded in setting it up correctly and it’s great now.
Thanks for the useful post.
Hi all,
I followed this tutorial and it didn’t work, we’re using WordPress 3.9.8 basically adding this function to the theme’s function.php then calling it has no effect on the RSS feed, would advise against trying this and perhaps going with the plugin option – may be this blog is simply out of date?
Hi R Davies, may I ask why you’re using such an older version of WordPress? It’s best to test these things out on the latest versions. Either way, using the plugin method is better than modifying theme files, so yeah, you can go with that.
Is there a way to add the featured image to my rss feed in a way that it will show as hyperlinked back to the post it is associated with?
I use my feed to trigger a newsletter with my new content currently, and the title automatically hyperlinks. but the image does not (even though people obviously will try to click through from the image).
Is there a way to define how the image is added to the feed so that it would also inherit the hyperlink? or is this something I need to sort out on the campaign side? Seems so simple, but can’t find a solution for this.
Hi – Were you able to find a solution to this problem? I’m looking for the same thing. “Is there a way to add the featured image to my rss feed in a way that it will show as hyperlinked back to the post it is associated with? “
To link the featured image to its post, replace this line of code:
$content = ” . get_the_post_thumbnail( $post->ID, ‘thumbnail’, array( ‘style’ => ‘float:left; margin:0 15px 15px 0;’ ) ) . ” . $content;
with this:
$content = ‘‘ . get_the_post_thumbnail( $post->ID, ‘thumbnail’, array( ‘style’ => ‘float:left; margin:0 15px 15px 0;’ ) ) . ‘‘ . $content;
It formatted my code into a link 🙁
Trying again…
To link the featured image to its post, replace this line of code:
$content = ” . get_the_post_thumbnail( $post->ID, ‘thumbnail’, array( ‘style’ => ‘float:left; margin:0 15px 15px 0;’ ) ) . ” . $content;
with this:
$content = ” . get_the_post_thumbnail( $post->ID, ‘thumbnail’, array( ‘style’ => ‘float:left; margin:0 15px 15px 0;’ ) ) . ” . $content;
I give up! The code is here: https://gist.github.com/anonymous/7644d45c437531c9e510f20827b8b739
Eeek! Thanks for this! And thank you EMILY for the info on getting my post to link! You all just made my day!
I’m having an issue where the RSS images src begins with // instead of https:// or http://
(issue with WPFC plugin with Photon CDN image servers creating the i3.wp.com , but the https:// is missing from the src )
so I’m trying to modifying this using the_post_thumbnail_url to fix a full src url into the posts, or modify further adding https: manually to the beginning of the src.
but the outcome places the entire post thumbnail url at the beginning:
https://mysite.com/wp-content/uploads/2017/12/image.jpg
modified function:
function featuredtoRSS($content) {
global $post;
if ( has_post_thumbnail( $post->ID ) ){
$content = ” . ” . ” . $content;
}
return $content;
}
add_filter(‘the_excerpt_rss’, ‘featuredtoRSS’);
add_filter(‘the_content_feed’, ‘featuredtoRSS’);
edit: example of an image tag that doesn’t load : src=”//i3.wp.com/mysite.com/wp-content/uploads/
`function featuredtoRSS($content) {
global $post;
if ( has_post_thumbnail( $post->ID ) ){
$content = ” . ” . ” . $content;
}
return $content;
}
add_filter(‘the_excerpt_rss’, ‘featuredtoRSS’);
add_filter(‘the_content_feed’, ‘featuredtoRSS’);`
Hello,
Thank you very much.
It works well for my Feedburner. The featured image is showing up properly.
However, in my Mailchimp campaigns only the alt-test and the border of the image show up.
Same when I test my feed here: https://www.coderedcorp.com/tools/rss-preview/
Could you be so kind and let me know what I’m doing wrong?
I used the exact code provided here in my functions.php
How about showing featured image caption?
I mean featured image with caption
Hi Crissy, I ran a quick search as I didn’t know how to do this. Check out this link:
https://stackoverflow.com/questions/13850313/how-to-add-a-featured-image-caption-in-wordpress
Let us know if it works for what you need 🙂
Just want to say your article is as surprising.
The clarity in your post is just nice and i can assume you’re an expert on this subject.
Well with your permission let me to grab your RSS feed to keep up to
date with forthcoming post. Thanks a million and please continue the enjoyable
work.
That’s awesome! Which plugins are you using exactly?
Hi,
The plugin works great for showing recent posts but when I add this code for pulling images it does nothing http://prntscr.com/mv4qyx (far down the home page). I’m pulling an RSS feed from a Hubspot blog to a wordpress website. Is it possible to pull those featured images?
Thanks!
Hey Tori, what do you mean when you say it does nothing? The screenshot shows the list presented by our free core plugin.
If you’d like to show featured images, you may opt for our Feed to Post add-on or Excerpts & Thumbnails.
Ok, I must have misread. Thank you.
is this working for RSS reader wordpress widget…?? i looking for way to insert thumbnails image in rss widget..anyone..?
I have been using this code as a snippet for a long time now. Yesterday MailChimp gave me an error that my feed would not validate. I deactivated this snippet and added the “Featured Images in RSS for Mailchimp & More” and all seems to be working now. I am not a coder by any stretch of the imagination but thought you should know. Also the Add Featured Image to RSS Feed plugin you recommend hasn’t been tested with the latest 3 major releases of WordPress.
Thanks