WordPress: Broken RSS Feed

This is one of the worst bugs I’ve encountered in a while. The worst because you really don’t know exactly where the issue can be fixed…

If you go to your site’s RSS feed (http://YOUR_SITE_URL/feed), you might see this message:

XML Parsing Error: XML or text declaration not at start of entity
Location: http://YOUR_SITE_URL/feed
Line Number 3, Column 1:
<?xml version=”1.0″ encoding=”UTF-8″?><rss version=”2.0″
^

Vague… i know

There are a bunch of responses out there if you Google the error, but nothing specific. The main takeaway is that you have a space between two adjacent php calls.

<?php foo ?>
[extra line break here]
<?php foo ?>

Instead, you’ll want it to look like so:

<?php foo ?>
<?php foo ?>

Or even better:

<?php foo
foo ?>

This not only can be caused by a faulty functions.php file, but ANY theme file and/or plugin.

In my editing program, I was able to do a regex search for the following:

\\?>\n\n

The search found several files in my theme and within a plugin. Removed the offending blank line and boom-yer-pregnant!

I noticed this weird issue affected another thing (maybe others)… When you click “Edit Image” in the “Edit Media” screen, the thumbnail won’t show up.

Screenshot_2

Another way to spot this issue is if you see an unintended first blank line in your website’s source code. If you didn’t mean to put that there, then there’s a blank line error in one of your files.

Leave a Reply