Thursday, March 30, 2017

WordPress Sitemap error XML declaration allowed only at the start of the document

I was geting the following error when viewing the xml sitemap that has been generated by the plugin YOAST

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.

Please note this not related to the plugin generating Sitemap. Usually this error occurs when there are white spaces before XML Tag declaration


Directly go to you functions.php file:

  1. Login to wordpress -> Appearance -> Editor -> Theme Functions (functions.php)
    You will find this file on right side column.
  2. In the editor look for ?>  this is where PHP server tags end and next php tag  see the picture remove all the line break like this
  3. Remove all empty lines between tags ?> and
  4. Save the functions.php 
  5. Refresh the page and check the sitemap now




Read More >>

Popular Posts