Skip to content

Instantly share code, notes, and snippets.

@hlashbrooke
Created July 12, 2013 11:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hlashbrooke/5983688 to your computer and use it in GitHub Desktop.
Save hlashbrooke/5983688 to your computer and use it in GitHub Desktop.
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
Copy link

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
Copy link

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