Skip to content

Instantly share code, notes, and snippets.

@leowebguy
Created April 11, 2016 17:46
Show Gist options
  • Save leowebguy/3c20c901d2e56ce62451c243dfcfa12c to your computer and use it in GitHub Desktop.
Save leowebguy/3c20c901d2e56ce62451c243dfcfa12c to your computer and use it in GitHub Desktop.
Here is a hook to add the featured image to your rss feed on WordPress
/*********** ADD IMAGES TO RSS FEED
you can set the position of the image changing the order like this
$content = $content . get_the_post_thumbnail( $post->ID, 'thumbnail' );
*/
function featured_images_rss($content) {
global $post;
if ( has_post_thumbnail( $post->ID ) ){
$content = get_the_post_thumbnail( $post->ID, 'thumbnail' ) . $content;
}
return $content;
}
add_filter('the_excerpt_rss', 'featured_images_rss', 1000, 1);
add_filter('the_content_feed', 'featured_images_rss', 1000, 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment