Created
June 9, 2014 23:02
-
-
Save EnragedSuccubus/718dbeccf6204b28ab76 to your computer and use it in GitHub Desktop.
Add an image to your WordPress RSS 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
// Add to functions.php and namespace your methods! :) | |
function cg_rss_post_thumbnail( $content ) { | |
global $post; | |
if ( has_post_thumbnail( absint( $post->ID ) ) ) { | |
$content = '<p>' . get_the_post_thumbnail( asbint( $post->ID ) ) . '</p>' . get_the_content(); | |
} | |
return $content; | |
} | |
add_filter( 'the_excerpt_rss', 'cg_rss_post_thumbnail' ); | |
add_filter( 'the_content_feed', 'cg_rss_post_thumbnail' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment