Skip to content

Instantly share code, notes, and snippets.

@indeedably
Last active September 5, 2018 19:51
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 indeedably/f0d0d4d1fc7d0d403d2f0efabbb7111f to your computer and use it in GitHub Desktop.
Save indeedably/f0d0d4d1fc7d0d403d2f0efabbb7111f to your computer and use it in GitHub Desktop.
How to include thumbnail images in Wordpress RSS feeds
/*
By default Wordpress does not include post thumbnails in RSS feeds.
To enable:
1. Open your Wordpress theme's functions.php file located in /wp-content/themes/[YOUR THEME]/
2. Paste the code snippet below into your functions.php
3. Save to have the changes take effect.
*/
function thumbnails_in_feeds( $content ) {
global $post;
if( has_post_thumbnail( $post->ID ) ) {
$content = '<p>' . get_the_post_thumbnail( $post->ID , 'medium_large') . '</p>' . $content;
}
return $content;
}
add_filter( 'the_excerpt_rss', 'thumbnails_in_feeds' );
add_filter( 'the_content_feed', 'thumbnails_in_feeds' );
@indeedably
Copy link
Author

Sample output here:

how to include thumbnail images in wordpress rss feeds

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment