Created
May 9, 2019 11:20
-
-
Save iamkingsleyf/e22c15acf80f93e1b9e61837f5e2d0e7 to your computer and use it in GitHub Desktop.
add featured image to wordpress 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
/* ---------------------------------------------------------------------------- | |
FEED FEATURED IMAGE | |
*/ | |
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'); | |
/* ---------------------------------------------------------------------------- | |
END FEED FEATURED IMAGE | |
*/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment