Display Post Thumbnails in the Feed

Lots of themes these days make use of post thumbnails or featured images but these aren’t included in your RSS feed by default. To add them in, add the following to your theme’s functions.php file.

1
2
3
4
5
6
7
8
9
10
// show post thumbnails in feeds
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');
// show post thumbnails in feeds
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');

Source: digwp

Related Posts:

  • Delay RSS Feed publishing
    You hit "Publish" instead of "Save Draft" or "Preview" on the post you are working on and have to hurridly edit it and put it back into draft status. Or you may notice some glaring error that needs co...

Tags: , , , ,

24.Sep.11 Tips


You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.

Leave a Comment

:)