Picture of Jean Galea

Jean Galea

Jean is the founder of WP RSS Aggregator and has a passion for content curation. However, his interest is not limited to the digital world; it extends to the holistic approach of health & fitness, the expressive world of art, the refined pleasures of gastronomy, and the enriching experiences of slow travel.

Table of contents

Streamline your
content-sharing process

Get started with WP RSS Aggregator today and unlock the full potential of RSS feeds!

How to Add a Featured Image to RSS Feeds in WordPress

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.

Article by

Article by

Share the Post:

27 Responses

  1. 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)?

    1. “Description” was deleted in my original post. It should read:
      my image is added to the “description” tag in the RSS feed…

  2. 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.

  3. 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?

    1. 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.

  4. 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.

    1. 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? “

    1. 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;

  5. 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’);

    1. `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’);`

  6. 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.

  7. 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!

    1. 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.

  8. is this working for RSS reader wordpress widget…?? i looking for way to insert thumbnails image in rss widget..anyone..?

  9. 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

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Articles