• Resolved skatetg



    When I try to load my sitemap page, I keep getting this error:
    This page contains the following errors:
    error on line 2 at column 6: XML declaration allowed only at the start of the document
    Below is a rendering of the page up to the first error.

    I have run through all documentation and the issue still persists!
    I have:
    – Deactivated all plugins
    – Switched themes
    – Even deactivated yoast and the issue persists
    – I have looked throught the functions.php and other core files but don’t see any issues.

    Can someone help? I’m sooo frustrated right now!!!!

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

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter skatetg


    I also created an install on a different host, so hosting shouldn’t be the issue here.

    Plugin Support Michael Tiña



    This typically happens when a plugin or theme function incorrectly adds an empty whitespace at the beginning of the sitemap.

    Upon checking the page source of your XML sitemap, there is indeed an extra whitespace at the beginning of the sitemap — http://newilp.staging.wpengine.com/sitemap_index.xml

    As much as we’d love to help, our plugin does not cause this issue. However, the cause most often is an empty line at the end of the functions.php file. If there is no empty line in this file, we highly recommend running a conflict check to identify what outputs the empty whitespace. You may also need to clear your caching from your plugins/theme/CDN such as Cloudflare/server caching etc. If you are not sure how to clear caching please speak with your developers or contact your host provider.

    Once you have identified whether your theme or a plugin causes the issue, please contact the developers of the theme or plugin for assistance finding and removing the whitespace.

    You can read more about it here — https://kb.yoast.com/kb/xml-sitemap-error/

    Thread Starter skatetg


    I had reached out to our hosting support at WP Engine, and they had assured me it was nothing on their end! Doing further testing, I cloned the site over to one of my siteground accounts and figured that it WAS an issue with one of WP Engine’s plugins within the wp-content/mu-plugins folder and that every time I deleted it, there was a script that would re-add the plugins.
    Very frustrated with them, but am definitely relieved.

    Thanks for your help!

    Hey everyone, I just had this issue and it turned out I had an extra blank line in my child theme’s functions.php file after the ?> bracketed section.

    Removing the blank line solved this issue for me 🙂 hope it helps someone



    Thanks @zenakos, it worked for me

    Unfreakin’believeable. I would not have found this in a year of trying. Thank you so much for taking the time to give us places to look. I had two spaces after the close php.

    @skatetg – what was that WPE MU plugin?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Sitemap error: error on line 2 at column 6: XML declaration allowed only at the’ is closed to new replies.