• Resolved CryptoNewsZ

    (@cryptonewsz)


    I’m facing two issues with my WordPress site CryptoNewsZ’s RSS feed, and I’d appreciate some help:

    1. RSS Feed Schema Error: I keep getting the following error when checking my RSS feed:
      “Schema error: XML document with no namespace; cannot determine any schema to use for validation.”
      After some research, I added the following code to my functions.php file, but it didn’t resolve the issue. Instead, I received a fatal error:

    “Fatal Error: duplicate attribute (found xmlns)”

    Here’s the code I tried:

    function add_custom_rss_namespace() {
    if (!has_action(‘rss2_ns’, ‘add_custom_rss_namespace’)) {
    echo ‘xmlns:content=”https://purl.org/rss/1.0/modules/content/” ‘;
    echo ‘xmlns:dc=”https://purl.org/dc/elements/1.1/” ‘;
    echo ‘xmlns:atom=”https://www.w3.org/2005/Atom” ‘;
    echo ‘xmlns:media=”https://search.yahoo.com/mrss/” ‘;
    }
    }
    add_action(‘rss2_ns’, ‘add_custom_rss_namespace’);
    add_action(‘atom_ns’, ‘add_custom_rss_namespace’);

    How can I resolve this error without duplicating the attributes?

    1. Adjusting Crawl Frequency for RSS Feed: I’d also like to adjust the crawl frequency of my RSS feed. I’ve tried adding this code to set the update frequency and ttl:

    function add_rss_update_frequency() {
    echo “hourly\n”;
    echo “1\n”;
    echo “60\n”; // Time-to-live (in minutes)
    }
    add_action(‘rss2_head’, ‘add_rss_update_frequency’);

    Is this the right way to adjust the crawl frequency, and will search engines honor these changes?

    Here is the link to my RSS feed:

    Thanks in advance for any help or guidance on how to resolve these issues!

    • This topic was modified 2 months, 2 weeks ago by Yui.
    • This topic was modified 2 months, 2 weeks ago by James Huff. Reason: redundant links removed

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello @cryptonewsz,

    The error “Fatal Error: duplicate attribute (found xmlns)” occurs because the code you tried to add defines namespaces multiple times. We can fix this by defining them only once at the beginning of the RSS feed. Try to use this code (adding to functions.php):

    function add_custom_rss_namespace() {
    $namespaces = array(
    'content' => 'https://purl.org/rss/1.0/modules/content/',
    'dc' => 'https://purl.org/dc/elements/1.1/',
    'atom' => 'https://www.w3.org/2005/Atom',
    'media' => 'https://search.yahoo.com/mrss/',
    );

    if (function_exists('has_action') && !has_action('rss2_ns', 'add_custom_rss_namespace')) {
    global $rss;
    $rss->namespaces = array_merge($rss->namespaces, $namespaces);
    }
    }
    add_action('rss2_ns', 'add_custom_rss_namespace');
    add_action('atom_ns', 'add_custom_rss_namespace');

    This code defines an array <code class=””>$namespaces to store the namespace prefixes and URLs. It checks if the <code class=””>has_action function exists and if the <code class=””>add_custom_rss_namespace function hasn’t been hooked to the <code class=””>rss2_ns action already (to prevent duplicates). If the conditions are met, it merges the defined <code class=””>$namespaces array with the existing <code class=””>$rss->namespaces array using <code class=””>array_merge. This ensures the namespaces are added only once.

    About the crawl frequency – unfortunately, WordPress itself doesn’t have built-in functionality to control the crawl frequency of your RSS feed for search engines. Search engines determine their own crawl frequency based on factors like your website’s content and update frequency.

    I hope you find this helpful, kind regards.

    Thread Starter CryptoNewsZ

    (@cryptonewsz)

    Applied it and looking fine at this moment, thanks for the support.

    • This reply was modified 2 months, 1 week ago by CryptoNewsZ.
Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.