Created
July 24, 2022 07:09
-
-
Save Yorlinq/db29990bc5731eab57eef8718fb5525a to your computer and use it in GitHub Desktop.
Display featured post thumbnail in RSS feed - WordPress
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
// Display featured post thumbnail in RSS feed | |
function yl_featured_image_in_rss_feed($content) { | |
global $post; | |
if (has_post_thumbnail($post->ID)) { | |
$content = '<div style="margin-top: 15px; margin-bottom: 15px;">' . get_the_post_thumbnail( $post->ID, 'medium' ) . '</div>' . $content; | |
} | |
return $content; | |
} | |
add_filter('the_excerpt_rss', 'yl_featured_image_in_rss_feed'); | |
add_filter('the_content_feed', 'yl_featured_image_in_rss_feed'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment