When I viewed any RSS (XML) page on my WordPress site, the page didn’t render correctly and instead displayed an error stating: XML declaration allowed only at the start of the document.
Upon viewing the page source I could see that the first line in the document was in fact blank line, and the second line contained the usual XML declaration:
<?xml version="1.0" encoding="UTF-8"?>
But what was causing it?
It turned out that the problem was with my custom theme. In Functions.php in my child theme folder, I had whitespace before the starting <?php and after the ending ?>. Once I deleted this whitespace and re-uploaded Functions.php to my web server, the blank first line was gone and all of my RSS pages rendered successfully! Hopefully this will enable you to solve the error message: XML declaration allowed only at the start of the document.

