X

How To Add the Featured Image to Your RSS Feed

Snippets by IsItWP

Are you looking for a way to add the featured image to your RSS feed? This snippet will display the featured image of the post in the RSS feed. It will display the image to the right of the first paragraph of your content, but you can change the CSS in the snippet to modify the layout.

Instructions:

All you have to do is add this code to your theme’s functions.php file or in a site-specific plugin:

add_filter( 'the_content', 'featured_image_in_feed' );
function featured_image_in_feed( $content ) {
    global $post;
    if( is_feed() ) {
        if ( has_post_thumbnail( $post->ID ) ){
            $output = get_the_post_thumbnail( $post->ID, 'medium', array( 'style' => 'float:right; margin:0 0 10px 10px;' ) );
            $content = $output . $content;
        }
    }
    return $content;
}

Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly copy / paste code snippets in WordPress, so you don’t accidentally break your site.

If you liked this code snippet, please consider checking out 12 Best WordPress Plugins for Affiliate Marketers.

Comments   Leave a Reply

  1. Great snippet, Hugh! 🙂

    How about hooking this on to “the_content_feed” and “the_excerpt_rss”?

Add a Comment Cancel reply

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!