in WordPress

Add Current Post Image Thumbnail To RSS Feed In Wordpress

In a previous post we went through how to add content after RSS feed in wordpress, now we can take this idea to add additional information to your RSS Feed. One thing about your RSS feed is that the user will not get to your information from your website, so if you have a post image thumbnail they will not see it from your RSS feed unless it is added to your post. So we can take the RSS hooks we learnt in the previous post and use this to add your post image thumbnail to the post. Below is the code snippet which will get the current post id and then get the post image thumbnail for this current post and then uses the_excerpt_rss and the_content_rss hooks to add this into the RSS feed.

function rss_post_thumbnail($content) {
    global $post;

    if(has_post_thumbnail($post->ID)) {
         $content = '<p>' . get_the_post_thumbnail($post->ID) . '</p>' . get_the_content();

    return $content;

add_filter('the_excerpt_rss', 'rss_post_thumbnail');
add_filter('the_content_feed', 'rss_post_thumbnail');

Subscribe To The Weekly Newsletter

Get weekly updates to your email