Blog: WordPress
Communication satellite dish

Add Featured Image To RSS Feed In WordPress

Avatar for John Locke

John Locke is a SEO consultant from Sacramento, CA. He helps manufacturing businesses rank higher through his web agency, Lockedown Design & SEO.

Let’s say you have a WordPress site, and the theme adds a Featured Image at the beginning of each post.

Here’s the problem. When you have an RSS feed, or an email campaign hooked into your RSS, that Featured Image doesn’t show up.

This happens because most themes add the Featured Image to posts as part of the WordPress template — that image isn’t natively part of the content.

When you publish those same posts to Facebook, Pinterest, or Twitter, those platforms find the Featured Image, but they use a different protocol — Open Graph — to accomplish this.

So how do we get our Featured Images into our WordPress RSS feed?

Luckily for us, there’s a way to do this, by adding the following code block to our theme’s functions.php file.


<?php
/**
 * Add Featured Image to RSS feed
 *
**/

add_filter( 'the_content', 'ld_featured_image_in_feed' );
function ld_featured_image_in_feed( $content ) {
    global $post;
    if( is_feed() ) {
        if ( has_post_thumbnail( $post->ID ) ){
            $feat_image_output = get_the_post_thumbnail( $post->ID, 'full', array( 'style' => 'height: auto;margin-bottom:2em;max-width: 600px !important;padding-top: 0.75em;width: 100% !important;' ) );
            $content = $feat_image_output . $content;
        }
    }
    return $content;
}
?>

Here’s a video explaining how to implement this code from the WordPress training specialists at Webucator.com.

Add Featured Image To RSS Feed In WordPress

What Is Happening In This Code Snippet

In the code above, we are adding a filter to the page content, running it through the function we are adding, using the global $post variable.

If the page content is in an RSS feed, the function looks for a Featured Image attached to each particular post.

If it finds a Featured Image, it stores it in a variable, along with some inline styles for our RSS email campaigns. We are keeping the image below 600 pixels in width, in order to fit the email templates. (MailChimp uses 600px).

The function then adds the Featured Image before the post content for each blog post in the feed.

What If I Don’t See My Images In My Feed URL?

The URL for your WordPress site RSS feed is usually http://yourwebsite.com/feed/.

If you use the <!--more--> tag in your posts to create a cut-off point for the Read More link, you may only see excerpts of your RSS feed, and may not see images at the traditional http://yourwebsite.com/feed/ URL.

This confused me, too, because I was seeing the full content of my RSS feed in Feedburner, and also in my MailChimp RSS preview.

Feedburner RSS

If you’re using the <!--more--> tag in your RSS feed, go to your feed URL, and Right-click > View Source. You should see the raw markup of your RSS feed, which should include images (and now) your Featured Image.

If you still only see excerpts in your RSS feed and the source code of that feed, log into your WordPress admin area. Go to Settings > Reading.

Reading RSS Settings in WordPress

Find the area that says, For each article in a feed, show — make sure you have this set to Full text, not Summary.

Avatar for John Locke

John Locke is a SEO consultant from Sacramento, CA. He helps manufacturing businesses rank higher through his web agency, Lockedown Design & SEO.

4 comments on “Add Featured Image To RSS Feed In WordPress

  1. This code works great — but we’re wanting only the Featured Image showing up in the feed and not the other images that are in the page. Is there a way to accomplish that?…i.e., excluding images inside the post from the RSS, but still including the featured image in the RSS.

  2. Hi Shelly:

    There’s not an easy way to remove just the content images from your RSS feed while leaving them intact on your blog. But this makes me wonder why you would be compelled to remove the images from the RSS feed at all.

    By chance, are you trying to remove the images from the feed because they are not fitting in the emails themselves. In other words, are the images going off the page?

    If that’s the case, you may want to try the Send Images to RSS plugin. This won’t remove the images from your RSS feed per se, but it will make the images email-friendly. You can also use a custom excerpt to go out to the RSS feed, so in theory, you could put the post in the custom RSS excerpt, just without images.

    I would test this with your particular theme on a staging server first. There is a great tutorial for this plugin on GretchenLouise.com.

    Let me know if this gets you closer to your end goal.

    Thanks,
    John

    1. Due to ads in our newsletter, our newsletter template is very narrow. We only want one image per story showing up. You have to scroll for eternity when there’s more than one story. We only want the featured image showing up, not images in the post.

  3. Hi Shelley:

    There’s a suggestion in the comment reply above. Did you try that? Using a custom excerpt minus images with the plugin suggested?

    If you try that, and are still unable to accomplish your goal, you may need to hire a developer to help you with your RSS feed. They may need to create a custom RSS feed template to keep images out of your feed. Here’s a place to start:

    https://gregrickaby.com/2014/03/custom-rss-template-wordpress/

    On a side note, are the ads an effective monetization strategy? Are they a reliable source of income?

    Thanks,
    John

Join the Conversation

Your email address will be kept private. Required fields marked *.