A web development/programming blog providing info, tips, and tricks on programming languages, scripting, Linux, MySQL and more
How to fix a broken WordPress RSS feed
Looking over my analytics for my blog the last couple days, I’ve noticed I have got a couple of referral visits from my web design company website. I added a FeedBurner widget to the front of that site highlighting my 5 most recent blog posts. Out of curiosity, I was browsing on that website and notice the Widget stated “Watch this space for future items!” Well that was just weird to me since I post every day. Upon further research, FeedBurner was showing an error “There is an issue that must be addressed with your source feed for the feed”. When I went to my actual feed URL, I got the following error:
XML Parsing Error: XML or text declaration not at start of entity
Location: http://www.poundbangwhack.com/feed/
Line Number 2, Column 1:<?xml version="1.0" encoding="UTF-8"?>
^
As I have preached before, you need to read the error code. The error above indicates that the problem is on Line Number 2, Column 1. If you know anything about XML, you know that all XML files have to start with the <?xml on the first line of your code. As indicated by the error message above, this is on the second line, meaning there is an empty line on line 1, which is causing the problems. Now there question is, how did it get there?
Sometimes the Plugin is the Problem, not the Solution
Let’s assume for a minute that your WordPress installation is correct and working and you have not modified any of the core WordPress files, which you shouldn’t need to do anyways, but some people still do (I have myself). The most common cause of this blank line is going to be your plugins.
On my blog I have two plugins I have written. One of them updates my Twitter status when I post, and the other is a plugin that simplifies adding new books to my tech library. However, I currently have 15 other plugins installed as well. I didn’t think at first it was one of my plugins, although that would be the most likely culprit as we can usually be safe in the assumption that if you downloaded the plugin from wordpress.org that the plugin is complete and works properly. I know I’m making a lot of assumptions here and plugins have been known to fight with each other on occasion.
The error is generally caused by a blank line at the end of the file after the last ?> tag. If you don’t want to (or didn’t) make the assumption I did, how do we check all the plugins to make sure they’re ok? It will be to time consuming to open up every file and check them all. The fastest way to do it? Deactivate all your plugins. This won’t change any configurations you have saved. Check your feed URL, it should be working. If not…you have bigger problems. One by one, reactivate your plugins and check your feed URL each time. As soon as it breaks, you’ve found the problem plugin. Open up the plugin’s php file(s) and scroll to the bottom of each one. If you have a blank line after the last ?> tag, delete it, save the file, and check your feed URL again. That should take care of it and your feed should be working now! In my case, it was my tech library plugin that was causing it, and I wrote that almost two weeks ago, meaning my feed had been broken for almost 2 weeks.

