Images are playing a bigger part of blogging, with themes that highlight the posts’ featured images becoming more popular, creating great visually appealing layouts. Even more so with the popularity of Pinterest and Facebook sharing, which uses an image from the page or post. Even with various methods for including specific Facebook OpenGraph code within your post, your content could be shared via other methods that don’t take the Opengraph information into account, like RSS and feed syndication or sharing services like the awesome DLVR.it or Feedburner.
UPDATE AUGUST 2013: I went ahead and created a WordPress plugin for this, since there were quite a few people not having success with editing their theme files. Please read the new post instead of trying to follow the more technical code modifications below!
Click here: WordPress Featured Images in RSS Feed plugin
Here’s a fairly simple way to include the featured image of your WordPress blog post in the RSS/Feedburner feed itself, so that services that syndicate or share via RSS, use it when posting to Facebook and other image-friendly sharing sites like tumblr or posterous, etc.
Edit your theme’s functions.php file (via FTP, your host’s File Manager, or WordPress’ Editor under Appearance) which is under the /wp-content/themes/themename/ folder, or create one if need be, and add these lines near the top:
function featuredtoRSS($content) {
global $post;
if ( has_post_thumbnail( $post->ID ) ){
$content = '' . get_the_post_thumbnail( $post->ID, 'thumbnail', array( 'style' => 'float:left; margin:0 15px 15px 0;' ) ) . '' . $content;
}
return $content;
}
add_filter('the_excerpt_rss', 'featuredtoRSS');
add_filter('the_content_feed', 'featuredtoRSS');
To display larger images instead, change the word ‘thumbnail‘ to ‘medium‘, ‘large‘ or ‘full‘. To remove the float so the image appears above your text, replace the content line above with this one:
$content = '<div>' . get_the_post_thumbnail( $post->ID, 'full', array( 'style' => 'margin-bottom: 15px;') ) . '</div>'. $content;
You should be able to preview your RSS feed using your favorite feed reader, but keep in mind services like Feedburner cache your feed, so expect to wait 12-24 hours for it to update before you see these changes.
For more WordPress support check out these helpful articles from our WordPress Expert Series:
Why the 1-Click WordPress Install Should Be Avoided
WordPress for Enterprise Facts, Myths, and Tips for Success
24 Comments
This is great content… very important for certain syndication scenarios. Oh wait, I wrote it, but hey it’s true.
What, you don’t have syndication scenarios? You need social sharing strategy? Content strategy? I know someone that can help. 😉
At the very least, leave a comment that you loved the blog post, I get a nickle for every one.
Thanks,
Rob
Dear lonelyblogger15,
This is a great post, a bit technical but useful for sure! I wanted to add that you can “resync” your feedburner feed and the changes should show right away for you. This should be helpful for QA.
Hi Miguel,
Thanks for the comment. Look, I found a nickel!
Ah yes, I was going to mention resync and pinging options in feedburner, but didn’t want to make it too Feedburner specific, and just waiting is easier. But for those that want to know, here’s where you can resync your feedburner feed:
http://feedburner.google.com/fb/a/troubleshoot – Click the big Resync near the bottom. Or have it refresh the feed by pinging it here:
http://feedburner.google.com/fb/a/ping
It is a bit technical, but there’s not yet a plugin that does this, hence the code. Ah, here’s a plugin that adds a logo (same for all posts) to your RSS feed, for the less technical:
http://wordpress.org/extend/plugins/rss-add-image-header/
I will also add that the code above kinda goes against my rule of editing themes directly – you should create a child theme for any style customizations, as a rule – so if you’re doing this plus other customizations, a child theme may be the better way to go. I’ve also seen similar tips that edit the core WordPress file wp-rss2.php, but please, never edit the core files – they may get overwritten with the next WordPress update.
As always, if anyone needs help with the more technical aspects of their web site, feel free to contact me, or attend one of my workshops: http://meetup.com/webhelp/
Thx,
DTR
[…] the full post at: How to Optimize RSS to Display Featured Blog Images Posted in Featured Articles, Social Media, Tips and Tricks, […]
[…] the full post at: 3 Surprising WordPress Uses Beyond Blogging for Business Posted in Featured Articles, Tips and Tricks, […]
[…] You might also check out our post on optimizing RSS to display featured blog images. […]
Thanks! I modified my feed based on this and now have thumbnails in my RSS feeds.
Good to hear! I should build a WordPress plugin that handles this… if I had the time. 😉
Thank you for actually describing how to fix this issue, after looking t about 25 blogs and forums and finding no real help.
I followed your directions of putting the code into functions.php but it still did not render my images in the feed syndications. I refreshed and pinged both my feedburner and my NetworkedBlogs syndications. Possibly because:
1. I may have placed the code in the wrong “top” area. Not really sure exactly what you meant.
2.My post images are inserted by custom fields. Is there a way to include images when inderted this way?
Hi Nancy,
Thanks for your comment, glad you liked it.
“Near the top” of the functions.php file is fine, anywhere in that file should work.
This code only works with the “Featured Image” of your blog post. For using custom fields, with a theme using that custom field, it wouldn’t work… although, you could try setting a Featured Image, as well as your custom field, and the theme may not even use the Featured Image, but this code will, and all would work well.
Hope that helps!
Hi there,
I’ve been trying to add the code but when I do, the site goes down and just shows, on a blank white page, the code that I tried to paste in?
Thanks for your help
I’ve been having the same issue as Louise below! Help! I’m afraid to “break” the site but I really want my featured images in my feedburner feed.
Ah, I didn’t see Louise’s comment from Feb until now… so let me address it and Scarlett’s now. Editing the functions.php file can be touchy, and can definitely mess up a site if you’re not careful. I’d say first and foremost, add the code near the top, but definitely below the <? at the very very top. If you're not used to code editing, I'd hire someone to do it for you. If you'd like me to do it for you, feel free to send me an email… rob at fandommarketing.com 😉
[…] to a theme by editing the theme’s functions file and manually adding the code (including one I wrote for Fandom Marketing), but 99% of the folks I talk to don’t understand how to do that. So, this plugin was born. […]
[…] Read the full post at: 3 Surprising WordPress Uses Beyond Blogging for Business […]
Hi,
Hum I can Try…just need to wait 24h 🙂
Thanks
[…] posts: How to Optimize RSS to Display Featured Blog Images, How Sprout Social Helps Brands Spread The Love, 5 Content Management Plugins for […]
Tried it, it works! thank you very much!
Just so you know, I put this in and my whole site crashed.
Hi Mark… yes you have to be very careful with the placement of the custom code… or it can break the site – but this post is from 2012, and there’s now a plugin mentioned that does all this for you, so use it instead: https://brandswithfansblog.fandommarketing.com/wordpress-featured-images-in-rss-plugin/
So kind of you to reply and show the correct link. I shouldn’t have messed with the code. The plug in works nice! I always love if I can find a feature in a plug in!
Worked for me. Thanks!
Great work. Super helpful! Thanks.
Plug in worked like a charm. Thank you!