Created
April 9, 2014 13:34
-
-
Save yanknudtskov/10271118 to your computer and use it in GitHub Desktop.
Add Featured Image to WordPress feeds
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
//Function to add featured image in RSS feeds | |
function featured_image_in_rss($content) | |
{ | |
// Global $post variable global $post; | |
// Check if the post has a featured image | |
if (has_post_thumbnail($post->ID)) | |
{ | |
$content = get_the_post_thumbnail($post->ID, 'full', array('style' => 'margin-bottom:10px;')) . $content; | |
} | |
return $content; | |
} | |
//Add the filter for RSS feeds Excerpt | |
add_filter('the_excerpt_rss', 'featured_image_in_rss'); | |
//Add the filter for RSS feed content | |
add_filter('the_content_feed', 'featured_image_in_rss'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment