• Register
0 votes

Problem :

My blog feed showing me following error today:

This page contains the following errors:

error on line 2 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

7.5k points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

I have also faced the same issue in the recent past. I did lot of research on it to get solution on the issue.  I did following steps to resolve the issue. I found that firstly you need to create the php file e.g. whitespacefix.php on your wordpress root directory with below content :


function ___wejns_wp_whitespace_fix($input) {

    $allowed = false;

    $found = false;

    foreach (headers_list() as $header) {

        if (preg_match("/^content-type:\\s+(text\\/|application\\/((xhtml|atom|rss)\\+xml|xml))/i", $header)) {

            $allowed = true;


        if (preg_match("/^content-type:\\s+/i", $header)) {

            $found = true;



    if ($allowed || !$found) {

        return preg_replace("/\\A\\s*/m", "", $input);

    } else {

        return $input;





Now open your index.php file and add the below line right after <?php tag



If above solution is not helpful for you then you can try the solution given below

Please check if one of the files included in either your theme, or a plugin, has an empty blank line before the starting of the file.

Firstly please deactivate all plugins, after that try to load your sitemap.xml link. If it works now, then one of the plugins is the culprit. If it still does not work, then you need to move on...

Secondly, just go through each and every one of the .php files that make up your WordPress theme. Find any starting empty lines.

Third, just reinstall WordPress core installation. If it still not working, then contact a developer to do the some deep diving into your source code.

38.6k points