Skip to content

Instantly share code, notes, and snippets.

@santosh
Created December 10, 2016 09:30
Show Gist options
  • Save santosh/3acc95d3ce0c19ef29a3bb2b000611b3 to your computer and use it in GitHub Desktop.
Save santosh/3acc95d3ce0c19ef29a3bb2b000611b3 to your computer and use it in GitHub Desktop.
Add these line of codes to functions.php of your theme; to display thumbnail of featured image of the post. #WordPress
/*===================
ADD IMAGE TO FEED
===================*/
// display featured post thumbnails in RSS feeds
function WPGood_rss_thumbs( $content ) {
global $post;
if( has_post_thumbnail( $post->ID ) ) {
$content = '<figure>' . get_the_post_thumbnail( $post->ID, 'large' ) . '</figure>' . $content;
}
return $content;
}
add_filter( 'the_excerpt_rss', 'WPGood_rss_thumbs' );
add_filter( 'the_content_feed', 'WPGood_rss_thumbs' );
/*===================
ADD IMAGE TO FEED ENDS
===================*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment