If you use the RSS feed for your WordPress blog, you might have noticed that the featured image isn’t included in the feed’s posts by default.
Including images in your RSS feed can enhance the way your content is shared and can be useful in the future, especially when tools like Mailchimp use RSS feeds to create newsletters.
In this simple guide, I’ll demonstrate how you can show your featured image in the WordPress RSS feed using a plugin or by adding a code snippet to your functions.php file.
Show Featured Image in WordPress RSS Feed Code Snippet
If you know how to edit the functions.php file, you can use the code below to make the featured image appear in your RSS feed.
Alternatively, you can use a plugin called “Code Snippets” if you prefer adding code to your site instead of installing multiple plugins. This plugin can be useful for managing your custom code snippets.
<?php //This will prepend your WordPress RSS feed content with the featured image add_filter('the_content', 'da_featured_image_in_rss_feed'); function da_featured_image_in_rss_feed( $content ) { global $post; if( is_feed() ) { if ( has_post_thumbnail( $post->ID ) ){ $prepend = '<div>' . get_the_post_thumbnail( $post->ID, 'medium', array( 'style' => 'margin-bottom: 10px;' ) ) . '</div>'; $content = $prepend . $content; } } return $content; }
Certainly, you have the option to change the HTML in the code snippet and use CSS to style the appearance of the featured image in your feed. However, it’s a good idea to keep the styling simple because you can’t predict how different users’ RSS readers will interpret the feed.
Show Featured Image in WordPress RSS Feed using a Plugin
If you’re not comfortable with coding and you want a WordPress RSS feed plugin that includes images, there are a few choices available. In this guide, we’ll use the “Featured Images in RSS” plugin found in the WordPress.org repository.
All you have to do is install and activate this plugin, and your WordPress RSS feed will automatically include images. The plugin also provides several choices regarding how you want the featured image to appear in relation to the content, whether you want it positioned above the content or aligned to the left or right side.
This is great if you’re looking for an easy way to add images to your WordPress site’s RSS feed. I hope this short guide was useful. If you have any questions or thoughts about using featured images in WordPress, feel free to share in the comments below!
Related Articles
Leave a Reply