WordPress.org

Forums

WordPress SEO by Yoast
[resolved] Sitemap error: XML declaration allowed only at the start of the document (7 posts)

  1. vekica
    Member
    Posted 4 years ago #

    Hi, strange error for me on sitemap funcionlity

    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.

    Demo: http://www.trcanje.rs/sitemap_index.xml

  2. Jon Cave
    WordPress Dev
    Posted 4 years ago #

    Check your themes functions.php file and other plugins for trailing whitespace (or opening whitespace) outside of the <?php and ?> tags. I think something is outputting whitespace before the SEO plugin has a chance to display the sitemap and that is the most likely cause.

  3. Simon
    Member
    Posted 3 years ago #

    This took me ages to fix, but think its working now on this site:

    http://www.jandrtutors.co.uk

    Thanks Jon - you are bang on with the cause - bit of custom taxonomy work resulted in white space at the bottom of functions file. Disabling plugins made no difference, try cleaning up you functions.php file first folks!

  4. Joost de Valk
    Member
    Plugin Author

    Posted 3 years ago #

    Yeah that's always a tricky one, I'm trying to see if there's a better solution but all the ones I've found so far are hackish :) Closing this thread.

  5. Simon
    Member
    Posted 3 years ago #

    Thanks for an awesome plugin though Joost.

    Maybe if poss, mention whitespace in functions.php in the error message? Could you even put a small function in that then attempts to remove possible offending white space?!

    Cheers
    Si

  6. Joost de Valk
    Member
    Plugin Author

    Posted 3 years ago #

    The error message isn't generated by the plugin but by the browser...

  7. itos
    Member
    Posted 3 years ago #

    I also got this problem in the RSS feed. But I didn't realize it, first the problem was that the wp-admin page shows a blank page. I have been 2 days trying to fix it and I realize that the problem was some blank space lines in the code in functions.php. Search for any blank line spaces between <?php and ?> and erase them. That should fix the RSS and other problems.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WordPress SEO by Yoast
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic