Posted by & filed under WordPress.

It’s often useful to spruce up your RSS feed with images and the simplest way to do this is to include your post’s featured image in the feed content. Some themes have an option to enable this, but if yours does not then you can use this snippet. 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.

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;
}

Leave a Reply

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