In this tutorial, i’ll show you how easy it to add a featured image from all your posts anywhere in your RSS feed. This tip works regardless of whether you’re using Feedburner or your default WordPress RSS feed address.
Simply add this code to the end of your child themes functions.php file using a code editor and your featured image will appear in your feed. This code works with any theme as it uses the standard WordPress hooks and filters.
You can easily style the images in your feed by modifying the values in this in-line CSS for:
- float-left – Easily change this to float right or align-none
- margin right – This adds a space between the image and text when the image is floated to the left
- height – This is the height you can set for the image in your feed
- width – And this is the settings for the width of the image
- border – This controls the border around the image which is a solid 2 px size light grey color
Note: You can only style your featured image in your feed using inline CSS. Adding a class to the PHP code and then styling your image from your themes style.css will not work.
Link Featured Image In RSS Feed Back to Single Post
This code includes a featured image which is linked back to the single post the featured image is attached to.
MEMBERS ONLY - PREMIUM CONTENT
Set RSS Image Size
There’s different way you can set the size for images in your RSS feed. The above code includes the name of a custom image size which has been added to the child themes functions.php file like this:
/** Add new image sizes */ add_image_size( 'rss-image', 300, 150, TRUE );
Another option is to use the default Media settings for image sizes and replace rss-image in the code to either:
- Thumbnail size – Use ‘thumbnail’
- Medium size – Use ‘medium’
- Large size – Use ‘large’
Media Settings – Image Sizes
You can use the size in the above settings to control the size of images in your feed as seen in the image size list above. When using these sizes you would remove the CSS code from the PHP snippet which controls the height and width.
Styling RSS Feeds Font
If you’re using Feedburner to manage your feed, you could also change the font size, font family and color of your font so the post excerpt aligns with the bottom of your image.
If your prefer to use a plugin, here’s 2 which get the job done:
Featured Image In RSS Feed – This plugin enables you to change the size of the post image in your feed otherwise it uses the thumbnail size set in your Settings > Media > Thumbnail Size.
Add Featured Image To RSS Feed – This plugin simply displays an image in your RSS feed using the Large size in your media settings.
Another option would be to add a conditional tag to the code if you only want thumbnails displaying in your feed from a specific category or to set other conditions.