Add Featured Image to WordPress feeds
//Function to add featured image in RSS feeds
function featured_image_in_rss($content)
{
// Global $post variable global $post;
// Check if the post has a featured image
if (has_post_thumbnail($post->ID))
{
$content = get_the_post_thumbnail($post->ID, 'full', array('style' => 'margin-bottom:10px;')) . $content;
}
return $content;
}
//Add the filter for RSS feeds Excerpt
add_filter('the_excerpt_rss', 'featured_image_in_rss');
//Add the filter for RSS feed content
add_filter('the_content_feed', 'featured_image_in_rss');