Last active
August 29, 2015 14:15
-
-
Save paulvanbuuren/36d036c935f0835faf78 to your computer and use it in GitHub Desktop.
WordPress: Featured Images in RSS Feed
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
// from: http://www.codeinwp.com/blog/wordpress-image-code-snippets/ | |
// ============================================================================ | |
// Show Featured Images in Your WordPress Blog’s RSS Feed | |
// By default, featured images are not shown in your blog’s RSS feed. This is no good at all, and is high on my list of must-change // tasks when designing a new site. | |
// | |
// Fortunately, the solution is simple enough. Just use the following code snippet: | |
// ============================================================================ | |
add_filter('the_content_feed', 'rss_post_thumbnail'); | |
function rss_post_thumbnail($content) { | |
global $post; | |
if( has_post_thumbnail($post->ID) ) | |
$content = '<p>' . get_the_post_thumbnail($post->ID, 'thumbnail') . '</p>' . $content; | |
return $content; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment