In this tutorial, I will show you how to add post thumbnail to rss feed in WordPress using very simple few line of code without using any plugin. This code working fine for add WordPress featured image RSS feed address. This will take just few minute.
First we need to add some code to your website. Open your website theme function.php file and put below code into function.php file and save.
function featuredtoRSS($content) { global $post; if ( has_post_thumbnail( $post->ID ) ){ $content = ' ' . get_the_post_thumbnail( $post->ID, 'thumbnail', array( 'style' => 'margin-bottom: 15px;' ) ) . ' ' . $content; } return $content; } add_filter('the_excerpt_rss', 'featuredtoRSS'); add_filter('the_content_feed', 'featuredtoRSS');
In get_the_post_thumbnail() function you can also use medium and large instant of thumbnail. according to your requirement of image size. for example:
$content = get_the_post_thumbnail( $post->ID, ‘large’)
Tags:
adding images to rss feed, wordpress import rss feed with featured image, wordpress rss feed plugin with image, rss feed with images example, wordpress rss feed image missing, rss feed to post wordpress plugin, wordpress rss image tag, wordpress rss thumbnail image
My name is Mukesh Jakhar and I am a Web Application Developer and Software Developer, currently living in Jaipur, India. I have a Master of Computer Application in Computer Science from JNU Jaipur University. I loves to write on technology and programming topics. Apart from this, I love to travel and enjoy the beauty of nature.