Skip to content

Instantly share code, notes, and snippets.

@miklb
Created January 20, 2018 15:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miklb/e75c5022b18de7c74a1b4912ade2bd71 to your computer and use it in GitHub Desktop.
Save miklb/e75c5022b18de7c74a1b4912ade2bd71 to your computer and use it in GitHub Desktop.
function to add featured image to feed
/**
* Featured image in atom feed.
* @method featuredtoRSS
* @param $string $content post content.
* @return $string $content updated content w/image.
*/
function independence_featuredtorss( $content ) {
global $post;
if ( has_post_thumbnail( $post->ID ) ) {
$content = '<div>' . get_the_post_thumbnail( $post->ID, 'medium', array(
'style' => 'margin-bottom: 15px;',
) ) . '</div>' . $content;
}
return $content;
}
add_filter( 'the_excerpt_rss', 'independence_featuredtorss' );
add_filter( 'the_content_feed', 'Independence_featuredtorss' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment