Wordpress

How to make your WordPress Featured Image appear in your RSS Feed

add the featured image inside your rss feed in wordpressAfter experiencing social media and how web sharing works, I understood that images are very important for the promotion of blog posts. Having been using WordPress for quite some time, I’ve seen that Featured Images are a great way to make an image appear differently on the main page and inside the post page and by using thumbnails you can have both worlds; beautiful and small thumbnails on the main page and a full image inside the post.

One problem that this has created though, is that WordPress by default does not show the Featured Post image inside your blog’s RSS feed. By adding the hook code below in functions.php of your theme, the post thumbnail will appear on the feed:

function custom_content_feed($content) {
    return wp_get_attachment_image(get_post_thumbnail_id(), 'full') . '<br />' . $content;
}
add_filter('the_content_feed', 'custom_content_feed');

If you would like the post thumbnail to be shown below the content, just change the second line to:

    return  $content . '<br />' . wp_get_attachment_image(get_post_thumbnail_id(), 'full');

Moreover, if an alternative image size is required, you can define it in the second parameter, e.g. replacing ‘full’ with ‘thumb’.

Of course, the wp_get_attachment_image documentation is available.

It’s actually easy to modify WordPress with just a few lines of code. More “WordPress Hacks” coming soon!

About the author

Nikolaos Anastopoulos

Nikos is an IT consultant providing professional services with broad experience on data analysis, data migration and web development. Being part of the Moneytized team, Nikos migrates his expertise on Information Technology with Internet marketing, resulting in high quality Internet implementations. More on his profile.

6 Comments

Leave a Comment