Last active
October 6, 2020 08:14
-
-
Save DeveloperWil/fce020cfb5ec116cae3b29d08aaef80a to your computer and use it in GitHub Desktop.
Add Featured Image To WP RSS Feed
This file contains hidden or 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
| <?php | |
| //This will prepend your WordPress RSS feed content with the featured image | |
| function wbd_featured_image_in_rss_feed( $content ) { | |
| global $post; | |
| if( is_feed() ) { | |
| if ( has_post_thumbnail( $post->ID ) ){ | |
| $prepend = '<div>' . get_the_post_thumbnail( $post->ID, 'medium', array( 'style' => 'margin-bottom: 10px;' ) ) . '</div>'; | |
| $content = $prepend . $content; | |
| } | |
| } | |
| return $content; | |
| } | |
| add_filter('the_content', 'wbd_featured_image_in_rss_feed'); | |
| add_filter('the_excerpt_rss', 'wbd_featured_image_in_rss_feed'); | |
| add_filter('the_content_feed', 'wbd_featured_image_in_rss_feed'); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this to your theme's functions.php file