Created
December 19, 2019 12:23
-
-
Save deeman/311882ed4dedf81bfae35db97b67b275 to your computer and use it in GitHub Desktop.
Add Featured Image in 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 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