Skip to content

Instantly share code, notes, and snippets.

@dannydover
Last active November 19, 2018 18:18
Show Gist options
  • Save dannydover/76e8bd1c31ca011de2bcdb412a555ce7 to your computer and use it in GitHub Desktop.
Save dannydover/76e8bd1c31ca011de2bcdb412a555ce7 to your computer and use it in GitHub Desktop.
Show Featured Image in Wordpress RSS Feed - Credit: https://woorkup.com/show-featured-image-wordpress-rss-feed/
<?php
/* Add Featured Image to beginning of RSS Feed entries */
function featuredtoRSS($content) {
global $post;
if ( has_post_thumbnail( $post->ID ) ){
$content = '<div>' . get_the_post_thumbnail( $post->ID, 'large', array( 'style' => 'margin-bottom: 15px;' ) ) . '</div>' . $content;
}
return $content;
}
add_filter('the_excerpt_rss', 'featuredtoRSS');
add_filter('the_content_feed', 'featuredtoRSS');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment