WordPress Snippets at WPcustoms

Show featured image in rss feed

this adds the featured image to your RSS feed. customize the css style if required and feel free to add any other html to the $content.


/**
 * Snippet Name: Show featured image in rss feed
 * Snippet URL: https://wpcustoms.net/snippets/show-featured-image-rss-feed/
 */
  function wpc_featured_image_in_feed( $content ) {  
    global $post;  
    if( is_feed() ) {  
        if ( has_post_thumbnail( $post->ID ) ){  
            $output = get_the_post_thumbnail( $post->ID, 'medium'  );  
            $content = $output . $content;  
        }  
    }  
    return $content;  
}  
add_filter( 'the_content_feed', 'wpc_featured_image_in_feed' ); 
add_filter('the_excerpt_rss', 'wpc_featured_image_in_feed');