XML Parsing Error – This page contains the following errors

This page contains the following errors:

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

or

XML Parsing Error: XML or text declaration not at start of entity

XML declaration error in XML Sitemap

As frustrating as this is, unfortunately it’s not something that can be “fixed” in All in One SEO, and requires a bit of troubleshooting to determine what file is causing it.

If you’re getting this error, this indicates headers have already been sent, usually caused by another PHP file outputting blank lines. Normally this happens when a poorly written plugin or theme’s PHP file is incorrectly outputting a closing PHP ?> tag, followed by some extra lines.

There are three possible culprits:

  1. Another plugin – You can use these instructions to narrow down the offending plugin/plugins. Once you find the plugin, you can either deactivate it, look for the file(s) with a closing PHP tag followed by blank lines and remove it, and/or contact the developer with the bug report.
  2. Your theme – Similar to #1,  use these instructions to determine if it’s your theme that’s the problem. Install a fresh and unmodified copy of one of the default themes (Twenty Nineteen, Twenty Twenty, etc). If the problem goes away, you know it was your theme.
  3. WordPress core – This would only be a problem if either you’re on a really old version of WordPress (upgrade!) or else you’ve modified core files (don’t!).
Whitespace after the closing PHP tag

Wherever you find this closing PHP tag, remove it.