How to add featured image to RSS in WordPress

Since I updated my blog with this new theme I started to use WordPress post formats.
But I found a problem when I used the post format Image or if I used a featured image as a part of the post. Write about the picture or just posted an image without any text to post. Everything looked fine until I checked the RSS. It just got the headline and nothing more or some text chatting about a picture doesn’t exist.

So here you got the solution:

// Add this in the functions.php
if ( !function_exists( 'add_featured_image_to_rss' ) ) {
	function add_featured_image_to_rss( $content ) {
		global $post;
		if ( has_post_thumbnail( $post->ID ) ){
			$content = get_the_post_thumbnail( $post->ID, 'large' ) . $content;
		}
		return $content;
	}
}
add_filter( 'the_excerpt_rss', 'add_featured_image_to_rss' );
add_filter( 'the_content_feed', 'add_featured_image_to_rss' );

Kommentera

E-postadressen publiceras inte. Obligatoriska fält är märkta *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>