facebook transparent twitter
Go Back  

SawFirst Forum

> SawFirst - About Your Virtual Presence > Websites

Websites Let us know about your website or any other website you find helpful, here.

Reply
 
Thread Tools
  #1  
Old 05-24-2021, 12:30 PM
Pretty Girl's Avatar
Pretty Girl Pretty Girl is offline
POST ADDICT
 
Join Date: Jul 2019
Location: Manila
Posts: 2,272
Default How to add featured Image to Wordpress RSS Feed

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');
that's all!!!
__________________
Reply With Quote
  #2  
Old 05-25-2021, 08:42 PM
Pretty Girl's Avatar
Pretty Girl Pretty Girl is offline
POST ADDICT
 
Join Date: Jul 2019
Location: Manila
Posts: 2,272
Default

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;
}
__________________
Reply With Quote
Reply

Tags
add, featured, feed, image, rss, wordpress
Thread Tools



CONTACT US
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.