How to show WordPress post thumbnails in feeds

Adding images to your RSS feed is a good way to give more visual effect to your articles. Below function will allow you to display post thumbnails within your RSS feed.Just add the code to your functions.php file in WP theme folder.

 
<?php
	// show post thumbnails in feeds
	function new_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', 'new_post_thumbnail_feeds');
	add_filter('the_content_feed', 'new_post_thumbnail_feeds');
?>

Related posts:

HTML5 page structure

HTML5 offers more powerful structure comparing to older versions of Html. There are many new …


Partner with Us

We are providing an exclusive partnership offer to individuals and companies who are interested in setting up their own web design & development company. For more information about how to partner with us, please contact us