• Hi,

    I am trying to show featured image in the RSS feed. For the purpose, I added <image> node under <item>. The Feed is something like this

    <item>
    <image>
    <url> … </url>
    <title>… </title>
    <link>… </link>
    </image>
    </item>

    This is as per the valid W3C RSS2.0 syntax as explained here.

    Although, when I try to validate my RSS Feed on https://validator.w3.org/
    It displays below message:
    Sorry, This feed does not validate.
    line 8, column 205: Undefined item element: image

    How to fix this issue?

Viewing 5 replies - 1 through 5 (of 5 total)
  • 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.

    Thread Starter joshibhargav20

    (@joshibhargav20)

    Hi Karthik,

    Thanks.

    I’ll try this.

    Thread Starter joshibhargav20

    (@joshibhargav20)

    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.

    Thread Starter joshibhargav20

    (@joshibhargav20)

    
    <?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.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘RSS Feed Validation Undefined item element: image’ is closed to new replies.