Sitemap error: error on line 2 at column 6: XML declaration allowed only …

error on line 2 at column 6

Today I faced with the problem of my sitemap.xml file appearance in WordPress blog. When I typed itfaq.info/sitemap.xml there was the following error (the error screen you can see in featured image to this post ):

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.

How to fix error on line 2 at column 6: XML declaration allowed only at the start of the document WordPress?

First of all I want to explain you what this error means: it says that there is a problem with the work of your blog RSS feed. This error is usually happened if you have extra empty lines or spaces in functions.php file. For example, you have added some additional code to the end of
functions.php that had invisible spaces or lines.

So find in left panel ‘Appearance’, move to ‘Theme Editor’ and find in right panel ‘functions.php’. If you file ends with ‘?>’ check that there are no spaces after it, if it is – remove them. N.B. Don’t forget to create backup of the file that you are going to change. If something is going wrong you can restore the previous one.

If it does not help you and the error on line 2 at column 6 still present, install plugin Fix My Feed RSS Repair, it checks and removes empty lines in whole theme. When the problem is solved deactivate/remove the plugin.

IMPORTANT: If you installed plugin for cache, don’t forget to deactivate them or erase cached data, as the error (XML declaration allowed only at the start of the document) can visually remain though you solved it.

Check all from above and surely you problem with
This page contains the following errors:
error on line 2 at column 6:
‘ will be resolved, if no please write your problem in comment and let’s try to find the issue for you!

Good luck! 😉

2 Comments

  1. Dude! Thanks for this. I was searching for a solution and everybody was telling that remove space from functions.php or wp-config.php, there was no space there at all. After installing and using the above-mentioned plugin, the error was gone from my blog (www.nishant.blog). Thanks

    • Great that it helped you! Good luck! 🙂

Leave a Reply

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