![]() |
|
|
Websites Let us know about your website or any other website you find helpful, here. |
![]() |
|
Thread Tools |
#1
|
||||
|
||||
![]()
Featured Image in WordPress RSS Feed
If you’re going the functions.php route, just drop it in the bottom. If you don’t know what you are doing, make sure to backup your functions.php file before editing it in case you break anything. Code:
/** * add featured image to RSS feed */ function featuredtoRSS($content) { global $post; if ( has_post_thumbnail( $post->ID ) ){ $content = '<div>' . get_the_post_thumbnail( $post->ID, 'large', array( 'style' => 'margin-bottom: 16px;' ) ) . '</div>' . $content; } return $content; } add_filter('the_excerpt_rss', 'featuredtoRSS'); add_filter('the_content_feed', 'featuredtoRSS'); ![]() |
#2
|
||||
|
||||
![]()
You may also use this code:
Code:
/** * add featured image to RSS feed */ //This will prepend your WordPress RSS feed content with the featured image add_filter('the_content', 'smartwp_featured_image_in_rss_feed'); function smartwp_featured_image_in_rss_feed( $content ) { global $post; if( is_feed() ) { if ( has_post_thumbnail( $post->ID ) ){ $prepend = '<div>' . get_the_post_thumbnail( $post->ID, 'medium', array( 'style' => 'margin-bottom: 10px;' ) ) . '</div>'; $content = $prepend . $content; } } return $content; } |