How to Add Featured Image to RSS Feeds in WordPress

WordPressPosted on

1 min read

By default, the featured image isn’t attached to your WordPress site’s RSS feed. Mostly this is good as it is, but there are use cases we need to set a picture to show.

There are two solutions to attach an image to your RSS, using one is depending on the use case.

Add to the Content

The first solution is to prepend it to your RSS item content’s body. If you want to set an image for the readers, this is your solution.

function pine_post_thumbnails_in_feeds( $content ) {
    global $post;
    if( has_post_thumbnail( $post->ID ) ) {
        $content = '<div>' . get_the_post_thumbnail( $post->ID, 'your-image-size' ) . '</div>' . $content;
    return $content;

add_filter( 'the_excerpt_rss', 'pine_post_thumbnails_in_feeds' );
add_filter( 'the_content_feed', 'pine_post_thumbnails_in_feeds' );

Add as an Individual Item

The other solution is to set an individual image item which is parseable individually by any parser like MailChimp automated RSS campaign. I mostly need this solution to display images in MC automatic emails, but it is useful in many different ways.

In both cases we can set any images we need to query the correct one.

Need a web developer? Maybe we can help, get in touch!

Similar Posts

More content in WordPress category