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://www.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');  

0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x