Add Featured Images to RSS Feeds
Places the featured image at the top of each item in your RSS feeds, so feed readers and email newsletters show it.
Opens WPIDE on
Code
$wpide_feed_image = function ( $content ) {
$post = get_post();
if ( $post && has_post_thumbnail( $post ) ) {
$content = '<p>' . get_the_post_thumbnail( $post, 'large', array( 'style' => 'max-width:100%;height:auto;' ) ) . '</p>' . $content;
}
return $content;
};
add_filter( 'the_excerpt_rss', $wpide_feed_image );
add_filter( 'the_content_feed', $wpide_feed_image );
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.