Last active
September 5, 2018 19:51
-
-
Save indeedably/f0d0d4d1fc7d0d403d2f0efabbb7111f to your computer and use it in GitHub Desktop.
How to include thumbnail images in Wordpress RSS feeds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sample output here: