[Sloved] Error on line 1 at column 7 XML declaration In WordPress

Recently when I swap my free WordPress responsive theme to the fastest loading WordPress Theme  GeneratePress. It the best WordPress I’ve seen until now.

So now I come to the point When changed my WordPress Theme to GeneratePress. And open my website Sitemap.xml there an error display. “Error on line 1 at column 7: XML declaration allowed only at the start of the document” as shown the below screenshot.WordPress Sitemap Error

How To Fix XML Declaration Error In WordPress 

Generally, this error means that there is some whitespace in your template coding and to resolve the issue you’ve to clear that whitespace.

To remove the whitespace from your template that may also occur due to some new WordPress Plugin that you’ve installed recently or something else.  You’ll figure it out by yourself self-don’t worry just read the article till the end.

Follow The Step by Step Guides To Resolve SiteMap Issue In WordPress

1 # Deactivated All The Plugins on WordPress Website

You’ll have to deactivate all the on your website plugins aspect SEO plugin. Once you deactivated all the plugins now after that activate one plugin at a time and check your Sitemap.xml. By doing this you can figure out which plugin creating the bug on the website template.

If this doesn’t work move to the second method.

2 # Open Function. Php File In WordPress 

You can easily open the Function.php file from the Appearance section.  (Go to Appearance Section > Editor ). After opening template editor software, Find function.php in the right sidebar. Open it.

Note: Before editing in the Function. Php file makes its backup in case if something goes wrong. Just copy all the data to the Notepad

Check if PHP opening and closing tags are placed correctly without any whitespace. Will codes seem like >Php? and <php? you’ll find codes in the beginning and end of the file and if you find any space before or after these tags clear it After this hit the Update button.

In Case, If you follow all the above method and still you seeing Sitemap Error Then we’ve to make changes to Web Hosting

Login in to your Web Hosting and open Control Panel or Cpanel In case if you’re using Bluehost just like me then you already know how to open Cpanel in Web Hosting. After opening the web host control panel in the new tab in the web browser. Open the File Manager.

Now you’ll have to find the file named (wp-config.php) Go to the “Public.html” to find it.

Edit the wp-config.php file in a new tab and check both opening and closing PHP tags if you find any whitespace before this tag clears that space and updates the file.

sitemap error

Pro Tip: Basically, the bug mostly found on the wp-config.php or function.php controllers.