Created
January 20, 2019 16:30
-
-
Save adamlaki/9bea4f0530d72127f43f33d78e154763 to your computer and use it in GitHub Desktop.
How to Add Featured Image to RSS Feeds in WordPress - Add to the content body
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
<?php | |
function pine_post_thumbnails_in_feeds( $content ) { | |
global $post; | |
if( has_post_thumbnail( $post->ID ) ) { | |
$content = '<div>' . get_the_post_thumbnail( $post->ID, 'your-image-size' ) . '</div>' . $content; | |
} | |
return $content; | |
} | |
add_filter( 'the_excerpt_rss', 'pine_post_thumbnails_in_feeds' ); | |
add_filter( 'the_content_feed', 'pine_post_thumbnails_in_feeds' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment