Fix: WordPress Sitemap Error: “XML declaration allowed only…”

Have you seen a error similar to the one below while trying to access your WordPress Sitemap?

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.

Wordpress sitemap.xml error

I’ve looked around and one guy solved the problem by removing some PHP-code that indicates the PHP code ending or whatever you call it “?>” in his themes functions.php file.

Because apparently he had 2 of them which caused the sitemap error for him and someone else too in that thread.

But that was not the problem for me. The problem was because some idiot (me) had made a plugin and left linebreaks and spaces in the plugin PHP-file.

So check your WordPress plugins. Deactivate one at a time and hit F5.

Have fun! 😉

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.