wordpress logo

You are trying to create and submit a sitemap for your WordPress website probably using a plugin or your WordPress RSS feed has stopped working for some reason you get this error:

WordPress error on line 2 at column 6: XML declaration allowed only at the start of the document

Or:

 Sorry

This feed does not validate.

line 1, column 1: Blank line before XML declaration [help]

There’s a simple quick solution but you’ll need access to website’s backend and root folder.

1) Download the following file: https://wejn.org/stuff/wejnswpwhitespacefix.php

It has no virus, you can open it with notepad or any text editor and check.

2) After downloading, upload the .PHP file into your WordPress site ROOT directory. This is wherever the wp-config.php file is. Do not upload it into the themes folder, or the plugins folder.

If you don’t trust you know where this is, it’s ok. Leave a comment and I’ll help you.

3) EDIT your index.php file and add the following right after the first line:

include(“wejnswpwhitespacefix.php”);

So at the end, your index.php should look something like this:


<?php


include(“wejnswpwhitespacefix.php”);


define(‘WP_USE_THEMES’, true);


require(‘./wp-blog-header.php’);
?>

Some times you may have a different url from the one above so you must add it to the “include(“wejnswpwhitespacefix.php”);
” such as in the example below:

<?php

include(&#039./wordpress/wejnswpwhitespacefix.php&#039);

define(&#039WP_USE_THEMES&#039, true);

require(&#039./wordpress/wp-blog-header.php&#039);

You realize that the url is always in your file before the “./wp” in the “require” line meaning the site url here is, “&#039

That’s of course a condensed version of the index.php file and yours’ will probably have lots of comments and stuff in it. But the important thing is to add the include code right at the top and save. After that reload the feed page and/or your sitemap usually “https://yoursite.com/sitemap.xml/” and it’ll work!

It did for us!

Reach out in the comments if this worked for you or if you know of any other better solutions!

 

 

Author: Lawk

Lawk is a mozillian, director at Innovware and consults part time for Every1Mobile.

He loves open source, the open web, writing, reading and developing literacy tools that can teach the youth around the world especially in East Africa.

https://i0.wp.com/newslibre.com/wp-content/uploads/2015/02/wordpress-logo-3.png?fit=940%2C333&ssl=1https://i0.wp.com/newslibre.com/wp-content/uploads/2015/02/wordpress-logo-3.png?resize=200%2C150&ssl=1LawkHow-ToWebError on line 2 column 6,RSS Feed,Sitemap,wordpressYou are trying to create and submit a sitemap for your WordPress website probably using a plugin or your WordPress RSS feed has stopped working for some reason you get this error: Wordpress error on line 2 at column 6: XML declaration allowed only at the start of the document Or:  Sorry This...People Media