If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!
XML declaration allowed only at the start of the document
I have been having trouble with the above error when clicking the Subscribe to RSS link on the this site. At first everything is all right - then after I edit a post, the link stops working because the XML feed it produces has inserted 8 blank lines at the top.
The normal cure for this is to check all the PHP files you’ve changed (wp-confg.php for example), to ensure no blank lines or spaces or anything for that matter occur after the final closing PHP tag, nor before the first PHP tag. I checked this, I also removed all plugins, I re-installed Wordpress, I re-installed Thesis. All was well for a while, and then the error returned.
Solution
The RSS Feed problem is normally caused by extra lines and spaces at the bottom or top of PHP files. The files to check are the ones you edit - for example wp-config.php.
But because I am using the Thesis Theme, and have made customisations, there is another file I’ve had an opportunity to screw up. That file is custom_functions.php.
When I write customisations, I prefer not to have to escape all the HTML because it is being echoed within PHP. This means I end up stopping and starting the PHP file many times, to make room for the HTML in each custom function. For example, I do this :
<?
function add_logo(){
?>
<div id="lizzylogo">
<a href="homepage.html" width="497" height="88" alt="" /><img src="logo.png"></a>
</div>
<?
}
add_action('thesis_hook_after_title', 'add_logo');
?>
<?
function add_tagline(){
?>
<div id="lizzytagline">Web Tutorials . . .</div>
<?
}
add_action('thesis_hook_after_title', 'add_tagline');
?>
Blank Lines Added Between Functions in custom_functions.php
But unfortunately, I did this :
<?
function add_logo(){
?>
<div id="lizzylogo">
<a href="homepage.html" width="497" height="88" alt="" /><img src="logo.png"></a>
</div>
<?
}
add_action('thesis_hook_after_title', 'add_logo');
?>
<---- A number of blank lines between each function
<?
function add_tagline(){
?>
<div id="lizzytagline">Web Tutorials . . .</div>
<?
}
add_action('thesis_hook_after_title', 'add_tagline');
?>
Remove All Blank Lines Between Functions
You must make sure there are no blank lines between functions if you choose to write the custom functions in the way I have. (Doing it this way avoids having to escape everything in the HTML when echoing it from PHP.) But even after you have fixed this, the RSS feed is unlikely to work which will make you think you haven’t fixed the problem. This is a caching issue.
I run three browsers on my PC (Chrome, Firefox and IE7). I had to clear the cache in all of them, close them all down, reboot my PC and start them all up again to completely clear the problem.
I don’t know if the rebooting was entirely necessary. In my case it was as I have a Firefox problem at the moment. It is not closing down properly and a reboot was the only way to get it make a fresh start. Once this was done, the XML problems went away.










