Hello
Check this Code if it helps.
Add the following code at the bottom of your child theme’s functions.php file (If you don’t know what you are doing, make sure to backup your functions.php file before editing it), or to the Add Shortcodes Actions and Filters plugin.
function featuredImagetoRSS($content) {
global $post;
if ( has_post_thumbnail( $post->ID ) ){
$content = '' . get_the_post_thumbnail( $post->ID, 'thumbnail', array( 'style' => 'float:left; margin:0 15px 15px 0;' ) ) . '' . $content;
}
return $content;
}
add_filter('the_excerpt_rss', 'featuredImagetoRSS');
add_filter('the_content_feed', 'featuredImagetoRSS');
Thanks.
Hi,
the problem is not with the code.
Problem is with the RSS itself.
Could you help in figuring out why RSS feed is invalid for <image> node?
Can you please provide the feed?
Also, the website URL if you don’t mind.
Thanks.
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/">
<channel>
<title>...</title>
<atom:link href="" rel="self" type="application/rss+xml" />
<link> </link>
<description>....</description>
<lastBuildDate>...</lastBuildDate>
<language>...</language>
<sy:updatePeriod> hourly </sy:updatePeriod>
<sy:updateFrequency> 1 </sy:updateFrequency>
<generator>https://wordpress.org/?v=5.1</generator>
<item>
<title>...</title>
<link>...</link>
<comments>...</comments>
<pubDate>Tue, 05 Mar 2019 03:36:55 +0000</pubDate>
<dc:creator>
<![CDATA[]]>
</dc:creator>
<category>
<![CDATA[]]>
</category>
<guid isPermaLink="false">...</guid>
<description>
<![CDATA[]]>
</description>
<wfw:commentRss>...</wfw:commentRss>
<slash:comments>...</slash:comments>
<image>
<url>...</url>
<title>...</title>
<link>...</link>
</image>
</item>
</channel>
</rss>
Above is the example. You can assume multiple <channel>…</channel> nodes.