• 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

6 5 3
7,540 points

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.

9 7 4
38,600 points

Related questions

0 votes
1 answer 135 views
Problem : Currently I am trying to learn the Apache Maven. I have tried to write below code in Eclipse but it is giving below error to me: Error Message: &ldquo;No grammar constraints (DTD or XML Schema) referenced in the document&rdquo; My Code : <project xmlns="http:// ... > <version>3.0</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins>
asked Feb 27 mphil 2.3k points
1 vote
1 answer 62 views
Problem: I am very new to Web.xml coding. Currently I am facing serious problem because of my web.xml file. If I try to run my Apache tomcat 8 server then every time it shows me below error: Server tomcat v8.0 server at localhost failed to start. in eclipse. If I ... . This error made my life like the hell. So I am looking for the help from web.xml expert who can help me in fixing my problem.
asked May 18 Martin K 6.6k points
0 votes
1 answer 4 views
I am beginner in SOAP request and response. We are running a project where our client has provided us their WSDL file. Specially they need an attribute which accepts multiple values.
asked Sep 28 Daniel Anderson 4k points
0 votes
1 answer 28 views
All of the following values can be stored in a column that&rsquo;s defined as decimal(6,2), except A) -246.29 B) 0 C) 2479.95 D) 32492.05 What is the correct answer? Explain in detail why?
asked Jun 11 Hiba Waqar 160 points
0 votes
1 answer 265 views
Problem : I have spent over the 10 hours in finding the exception or the special character to find in the code but I am unable to find it. I have already checked every similar messages in here. I am facing below error: Syntaxerror: json.parse: unexpected character at line 1 ... my form after that I am sending all the inputs to the main.js to validate it. So, I am just looking for the third-eye.
asked Dec 23, 2019 alecxe 7.5k points