Fix WordPress Feed XML Parsing Errors (XML Declaration Not at Start)

Is your WordPress RSS feed showing “XML Parsing Error: XML or text declaration not at start of entity“? It happened to us in 2009: our feed stopped loading in every browser and FeedBurner stopped updating, yet Google Reader kept showing our posts, so we only found out when a friend told us. The cause was a blank line before the XML declaration. Here is how to fix WordPress feed XML parsing errors, updated for 2026.

Fix WordPress feed XML parsing errors

Quick answer: This WordPress feed XML parsing error almost always means something prints output before <?xml, usually a blank line or space before <?php or after ?> in your theme’s functions.php, wp-config.php or a plugin, or a PHP warning. Find it by switching to a default theme and disabling plugins, remove the extra whitespace (and drop closing ?> tags at the end of PHP files), clear your cache and validate the feed.

What the error looks like

Firefox shows the XML parsing error with “Line Number 2, Column 1”. Chrome says “XML declaration allowed only at the start of the document”. Both mean the same thing: there is something before the first line of the feed.

Firefox XML parsing error on WordPress feed

XML Parsing Error: XML or text declaration not at start of entity
Line Number 2, Column 1

How to fix WordPress feed XML parsing errors

  1. Check the feed. Open yoursite.com/feed/ and test it in the W3C Feed Validation Service. If the first line is blank, you have this problem.
  2. Clear caching first. Turn off or purge your caching plugin and CDN so you see the live feed while testing.
  3. Deactivate plugins one by one, or use the Health Check & Troubleshooting plugin, which disables plugins only for you without affecting visitors.
  4. Switch to a default theme like Twenty Twenty-Five. If the feed works, the problem is in your theme.
  5. Remove blank lines before the opening <?php and after any closing ?> in functions.php, wp-config.php and plugin files you have edited. The modern best practice is to leave out the closing ?> at the end of PHP-only files, so stray whitespace can never be sent.
  6. Check for a BOM. Some text editors save files with an invisible byte order mark. Save as “UTF-8 without BOM”.
  7. Look for PHP warnings. With WP_DEBUG on and errors displayed, a warning printed at the top breaks the feed. Log errors to a file instead of displaying them on live sites.

What fixed it for us

Disabling plugins did not help. Over FTP we found blank lines after the closing tags in several files, including wp-config.php, and a blank line at the end of our theme’s functions.php, which we had edited recently to separate trackbacks from comments. Removing the blank lines fixed the feed instantly.

blank line at end of theme functions.php

Today, do not edit WordPress core files; update WordPress instead, as current versions do not ship with this problem. Make theme edits in a child theme so updates never undo them.

Update services that read your feed

After fixing the feed, force services to fetch it again. If you use FeedBurner, see how to fix FeedBurner feeds not updating. Email newsletter tools and feed readers usually pick up the fix on their next check. Many readers are forgiving and showed our posts even while browsers failed, so check your feed in a browser regularly. Our list of popular feed readers shows what your readers may be using.

FAQ

Why does my WordPress feed show a blank first line?

A theme or plugin file outputs whitespace before the feed starts, usually from a blank line around PHP tags.

Does this error hurt SEO?

Search engines can still crawl your pages, but feed readers, email services and podcast apps may stop updating.

Is there a plugin to fix it?

Old “fix RSS feed” plugins stripped blank lines from PHP files automatically. It is safer to find and fix the actual file.

Found this useful? Share it with someone who needs it.

Get our free weekly email: new tech guides and tools, no spam.

New and updated tech guides, a free tool worth bookmarking and one useful pick, once a week. No spam, unsubscribe anytime.

One email a week. Unsubscribe anytime. See our privacy policy.

Fresh Tech Guides

Leave a Reply

Your email address will not be published. Required fields are marked *

46 Comments

  1. I got rid of this mess by spending only 5 bucks on Fiverr.

    https://www.fiverr.com/categories/programming-tech

  2. Thank you for the excellent tutorial with screenshots and a clear explanation! As a marketer and non-PHP coder, the discussions on the WordPress support forums about this issue that said “remove whitespace from PHP files” left me confused. Seeing your actual screenshots of where you removed the whitespace “line” was really helpful.

    Also, note to others to check your built-in WordPress code editor and not just the PHP files via FTP (Appearance > Editor). It was my functions.php file too but making the change via FTP in both my main and child themes didn’t override what was appearing in functions.php in the built-in editor.

  3. I am getting the same error but I just have a web applicqation with no php files. Can anyone help me ???

  4. Thank you. I had added some stuff to my functions.php file and left a couple blank lines at the end. I deleted them and resynced my feeds. Now they work.

  5. If this method doesn’t work because you have a heavily customized theme with a lot of php and room for error, follow these steps….

    https://fail.ghost.org/

  6. Thanks, friend! My blog feeds were not working, with this same error you told above, and this was also preventing my Newsletter from being sent automatically (it’s feed driven).
    I edited my functions.php file as you suggested, and it worked first time! You saved my blog! :D

  7. “Feedburner account > Troubleshooting > Resync Feed” This option regenerated my Feedburner Feed, but the feed in my site by the address mysite.com/feed still doesn’t work!

    WordPress have 1000’s of php files, I can’t check them all!

  8. The php closing tag ?> is not necessary at the end of a file. Get out of the habit of using it, and delete it when you find it. This applies only to ?> at the end of a file. Naturally you need it within a file where text is mixed with php.

    Almost all white space problems are caused by white space characters, usually a newline, after the ?> at the end of a file. This is harmful in many situations, not just feeds.

    When you omit the ?> at the end of a file, you cannot (obviously) have white space after it. And white space before the close is harmless.

  9. Thanks a lot…

    This guide is the best step by step guide on fixing an RSS feed… I sat unable to do anything for a few weeks…. fixing my feed..

    ultimately it was ur guide that led me to find the problem.. that was ultimately in my functions.php…

    thanks a ton again…

  10. If you disable all pugins, resinstall wp with latest updated fresh files, and use another theme, but problem still there, you will have to remove feed cache from your database:

    DELETE FROM `wp_options` WHERE `option_name` LIKE (‘_transient%_feed_%’)

  11. Excellent, +1, this is a very useful article, I was looking for one solution, you gave me serveral :)
    Thanks dude !

  12. Another alternative is use ob_clean(); method just before you want to return your results, this will clean the output buffer so that even if any empty lines going to output, it will be erased before pushing your response

  13. Hello,
    Iam getting a different type of error in my wordpress feed: techblazes.com/feed which says: error on line 660 at column 30: Input is not proper UTF-8, indicate encoding !
    Bytes: 0x1C 0x4F 0x70 0x65
    This made my feedburner feed to stop working correctly. Please help me..

  14. I dont know how can i thank you for this post
    i fixed my rss feed problem by wordpress rss feed fix plugin that you put in the post

    thank you very very very much

    1. Parse your feed to some XML validator: maybe it will help. Not only blank line could break your rss.

  15. There are many ways to fix this.. Read the below article..Nice one

    https://www.globinch.com/wordpress-rss-feed-xml-parsing-error/

  16. Thanks for the post. I have read about the whitespace problem. And rereading it made me check again and fixed my problem (that I overlooked). Just wanted to say thanks.

  17. I found this problem to actually be BLANK LINES at the end of the FUNCTIONS.PHP file. Delete those lines.

  18. I just like to say thanks for this info. I am still trying to fix my RSS Feed, but your info has been very helpful. Fingers crossed!!

  19. Wow, great post. I was having problem with wordpress for Blackberry and it wouldn’t work, then i found you post, now my blog is accessible from my Blackberry again “blackberry uses xmlrpc”

    Thanks,

  20. uff… you save my life… y tried with the plug-in and doesn’t work, so i start editing all the archives of my template and the ftp server and done! all came back to normally

  21. Man, I wish this was as easy as it being a functions.php problem! I went through all the steps but STILL get the same problem as originally described. I am baffled and do not know what to do next!

  22. thank you for this post!
    I finally located the culprit – functions.php – that was causing me headaches.

  23. Josh L,

    This was the same issue we were having. Thank you for pointing out that spaces between php tags can cause this same malfunction.

  24. Thanks for this post! In my case, it was also the functions.php file, but it was a blank line between two blocks of PHP, rather than at the beginning or end of the file.

  25. Hi there,
    I have been looking for some information wth regards to xml errors in wordpress. As I produce articles, now and then, I create errors by accident.

    Is there anyhting that I can do to correct these errors automatically or do these have to be manually corrected.

    You seem like the right person to ask and so I hope I have not hijacked your post with my queries.

    All the best
    Kazooli

  26. Turned out it was the functions.php for me, as well.

    I totally forgot that I had edited it just before upgrading to WP 2.8.4 for a cleaner function…and ended up creating a bunch of needless extra research for myself, to resolve the problem.

    For those of you who didn’t fall into the “functions.php” category…

    You might want to give the Fix-Rss-Feed plugin a try, it quickly removed blank lines from most .php files in the WordPress directories and would save you a lot of time:

    https://wordpress.org/plugins/fix-rss-feed/

    Just wanted to say thanks for mentioning the functions.php one…I am astonished I missed it.

    Cheers,
    Michael

  27. Your article help me to slove the problem.SO would you mind me to translate it to Chinese?

  28. I had the same problem… and the fix it. i’m install fix-rss-feed plugin. It works!

  29. Looks I have been hit too! Will check out tonite. I did customise my theme a lot lately with conditionally tagging in WP and I think this could have caused.

    Thanks for writing this up.

    I was clueless about this :) but did remember you writing about this.