Created
February 17, 2017 18:58
-
-
Save 2aces/2e44156d81a37beb49aebf33ba325165 to your computer and use it in GitHub Desktop.
Use this code snippet on functions.php file of a theme to add the featured image as a thumbnail to a WordPress RSS feed.
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
function aa_rss_post_thumbnail( $content ) { | |
$post_id = $post->ID; | |
global $post; | |
if( has_post_thumbnail( $post_id ) ) { | |
$content = '<p class="rss-feed-thumbnail">' . get_the_post_thumbnail( $post_id ) . | |
'</p>' . $content; | |
} | |
return $content; | |
} | |
add_filter('the_excerpt_rss', 'aa_rss_post_thumbnail'); | |
add_filter('the_content_feed', 'aa_rss_post_thumbnail'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment