Sitemap error: error on line 2 or 4 (number could vary) at column 6 (could vary): XML declaration allowed only at the start of the document

This page contains the following errors:

error on line 4 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.



Plugin SupportMichael Tina 


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 —
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 —



Answer that worked for me

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
0 0 vote
Article Rating
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x
%d bloggers like this: