Dukeo » WordPress » Post Thumbnail & RSS Feed: How To Improve Your Feed With an Image

Post Thumbnail & RSS Feed: How To Improve Your Feed With an Image

Steven WordPress

Since quite some time, WordPress includes a way to set a thumbnail image for your blog posts. I make extensive use of these thumbnails in the themes I get designed for all my WordPress blogs. But what about displaying post thumbnails in your RSS Feed?

To display post thumbnail in your WordPress blog’s RSS Feed, just paste the following code in the functions.php file of your WordPress theme:

function diw_post_thumbnail_feeds($content) {
  global $post;
  if(has_post_thumbnail($post->ID)) {
    $content = '<div>' . get_the_post_thumbnail($post->ID) . '</div>' . $content;
  }
  return $content;
}
add_filter('the_excerpt_rss', 'diw_post_thumbnail_feeds');
add_filter('the_content_feed', 'diw_post_thumbnail_feeds');

If you enjoyed this article,
Get email updates

Join for Free »