Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WordPress: Add featured image to RSS feed
<?php
add_filter( 'the_content', 'featured_image_in_feed' );
function featured_image_in_feed( $content ) {
global $post;
if( is_feed() ) {
if ( has_post_thumbnail( $post->ID ) ){
$output = get_the_post_thumbnail( $post->ID, 'medium', array( 'style' => 'float:right; margin:0 0 10px 10px;' ) );
$content = $output . $content;
}
}
return $content;
}
?>
@niteshchaudhry

This comment has been minimized.

Copy link

@niteshchaudhry niteshchaudhry commented Oct 29, 2014

Hi, I tried to add this to the theme function.php, and the website stopped working suddenly as I clicked on the update button. Now I am not even able to see my wordpress login page. I need some help....

@ange1martin3z

This comment has been minimized.

Copy link

@ange1martin3z ange1martin3z commented Dec 20, 2014

Hey @niteshchaudhry, just copy it from line 2 through 11.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.