After installing new versions of WordPress or some new plugins, it is common to experience an error in your WordPress feed rendering your feed totally useless. The common error message returned when your WordPress feed is queried is XML Parsing Error: XML or text declaration allowed only at the start of the entity. What this usually means is that there is a white space or unwanted characters before the < character in your feed XML.

Generally uninstalling the plugin or WordPress and reinstalling them would solve the problem but what if you did all that and you still have the error? This would mean that your readers will not be able to access your content through your feeds be it RSS or E-mail so this is how to solve it.

Open up the file feed-rss2.php in your wp-includes folder and look for the code below.

header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
$more = 1;

Immediately after this code, paste this lump of code after.

$out = ob_get_contents();
$out = str_replace(array('\n', '\r', '\t', ' '), '', $input);
ob_end_clean();

Then save this file and apply the same to the other feed files which you use i.e. feed-rss2-comments.php, feed-rss.php, feed-rdf.php, feed-atom.php, feed-atom-comments.php.That should solve your white spaces problems.

Preventive Steps

Here’s a few tips on preventing this incident from happening in the first place.

1 – Install WordPress properly by following all the steps.

Yes you should follow each and every step when you install WordPress or their plugins for that matter. Following the WordPress upgrade guidelines will ensure that you have a clean transition over to the newer versions of WordPress and plugins.

2 – Use a text editor which can remove the Byte Order Mark (BOM) from your files whenever you edit your files.

Downloading your files and editing them in the Windows Notepad program will introduce a BOM into your files and will return errors when validating your site or feed. Use software like Notepad++ to edit your files if you downloaded them and plan to edit them using Notepad.

3 – Check for validation regularly

Anytime you introduce something new, go get your site validated. It is a healthy practice to regularly check your site with the W3C Markup Validator and your feed with the W3C Feed Validation Service to detect errors in your page. This will make sure you get to the problem first before your readers do.

Reference: w3it.org