Skip to content

Instantly share code, notes, and snippets.

@terrytsang
Last active September 11, 2022 09:57
Show Gist options
  • Save terrytsang/ab849491d899f514514bf2640e0b5953 to your computer and use it in GitHub Desktop.
Save terrytsang/ab849491d899f514514bf2640e0b5953 to your computer and use it in GitHub Desktop.
Include the featured image into RSS feed
<?php
//add this code into your theme functions.php file
add_filter('the_content', 'tt_featured_image_in_rss_feed');
function tt_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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment