error on line 4 at column 6: XML declaration allowed only at the start of the document
https://wordpress.org/support/topic/sitemap-error-error-on-line-2-at-column-6-xml-declaration-allowed-only-at-the/
Hello,
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/
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