Skip to content

Instantly share code, notes, and snippets.

@deeman
Created December 19, 2019 12:23
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 deeman/311882ed4dedf81bfae35db97b67b275 to your computer and use it in GitHub Desktop.
Save deeman/311882ed4dedf81bfae35db97b67b275 to your computer and use it in GitHub Desktop.
Add Featured Image in WordPress RSS Feed
function featuredtoRSS($content) {
global $post;
if ( has_post_thumbnail( $post->ID ) ){
$content = '<div>' . get_the_post_thumbnail( $post->ID, 'medium', array( 'style' => 'margin-bottom: 15px;' ) ) . '</div>' . $content;
}
return $content;
}
add_filter('the_excerpt_rss', 'featuredtoRSS');
add_filter('the_content_feed', 'featuredtoRSS');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment