Welcome Guest! Login? Checkout

Recently I’ve been play IFTTT and Buffer to try and automate some of the promotion on this here blog. One of the interesting things I’ve been trying to do is use the post’s featured image to make the tweet stand out with rich content. Unfortunately, the first try on the post I wrote last week (the one launching Taxamo for Easy Digital Downloads v1.2), lead to a bit of embarrassment with this tweeted out.

Not ideal, so I took a look as to how to add the featured image to the RSS feed.

IFTTT uses the {{EntryImageUrl}} flag to grab an image. This is often the first image on the post, so the easiest way to make sure you add your image to your feed, before the content is displayed.

If you are using excerpt feeds, rather than full feeds, you can do this using the_excerpt_rss filter, which is run whenever the_excerpt_rss() function is called.

From doing a bit of research, I found this post from Hugh Lashbrooke that details how to add a featured image to an RSS Feed, which I’ve edited to use the RSS excerpt, rather than checking for the feed.

To add the featured image to the WordPress RSS feed excerpt, you can use the following code, added to your theme’s functions.php or a separate plugin.

That will place the image in the code fine. However, should you use IFTTT as discussed at the beginning of the post, and don’t include a featured image, that can lead to situations similar to the embedded tweet above. So it’s a good idea to include a default image. To do so, modify the above code to include an “else” statement, such as this:-

That will mean that should you tweet using IFTTT, you will still have images appearing. It’s a good idea to use an image such as your blog’s logo.

Finally, if you have full RSS feeds, then you will have to use the code Hugh provided in the post above. There’s also the_content_feed() filter, which could work as well, but I’ve not tested it.



Polite Disclaimer: I am welcome, open and willing for corrections to be shared in the comments (with corrections being added to posts and credited), and the comments field should be used to promote discussion and make this post better. I do not know everything and if anybody finds a better way to do something, then by all means please share it below.

However, I'm unable to offer support to posts. The reason being is that WordPress has tens of thousands of plugins and millions of themes. As such, finding out exactly why code doesn't work with your setup is a long process. If you wish for me to look at your code, please use the priority support area.

Comments asking support will be left on the site, but there is no guarantee of answer.

  • Leigh

    Hi Rhys, thanks for the post. I’ve gone ahead and added the featured image to my RSS feed, and I’ve included the {{EntryImageUrl}} in my ifttt recipe. However, it doesn’t post the image to Twitter, it only posts a link to the image. The name of the tag: {{EntryImageUrl}} suggests that this is all it should do. Can you confirm that by using this tag, that you’re getting the image displayed as part of your tweet?

    June 11, 2015 at 8:13 am

Comments are closed.