Created
January 20, 2018 15:10
-
-
Save miklb/e75c5022b18de7c74a1b4912ade2bd71 to your computer and use it in GitHub Desktop.
function to add featured image to feed
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
/** | |
* 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