Created
April 11, 2016 17:46
-
-
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
This file contains 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 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