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


sumon tripura said...

You have some really interesting blog posts on here! Glad I found it! I’m following you…Check out my blog if you get a chance! For more information legal herbal empire for sale

ewaste bangalore said...

Thanks for the marvelouѕ pοstіng! I really enjoyeԁ readіng іt, you may be a gгeat authοr.
I ωill be sure to boοkmark yοur blog and will
come back at somе point. I want to encouгage yоuгѕelf tо contіnue your greаt wгiting, have
а nicе day!
Electronic waste disposal bangalore, India

Popular Posts