January 4th 2009 by Peter · 14 comments
No More Invalid RSS
When I made this site, I spend hours figuring out why my feed wasn’t working. There are several examples in the WordPress Support Forums telling, that feeds aren’t working because of a blank line in the beginning of the feed before the XML declaration. Some feedreaders have no problem with this, but Feedburner does. And Feedburner is very important.
Well, let’s get to it! The fix was found at Wejn.org and is very simple to use. First of all, you need to download the script file, called wejnswpwhitespacefix.php and upload it to your blog’s root (in the same folder as index.php. Then, get your index.php file. It usually looks something like this:
<?php define('WP_USE_THEMES', true); /** Loads the WordPress Environment and Template */ require('./site/wp-blog-header.php'); ?>
Now, right before define('WP_USE_THEMES', true);, add include("wejnswpwhitespacefix.php");.
This will call the script, which removes every character that isn’t text before the XML declaration in the RSS files, and before the DOCTYPE declaration in the theme files.
Related posts:
14 comments so far
Trackbacks & Pingbacks
- WordPress 3.0 and the future of “Playing with Technology” | Playing with Technology
- Erro no Feed do Wordpress - Espaço em branco | Lula Ribeiro
- How to Avoid blank line in RSS??? « Er.Krushna Chandra Muni :: Professional Web Developer,Website Design Orissa,Website Design Bhubaneswar,Indian Freelancer,website design india
- RSS victory is mine







Where do I insert your code to fix?
My index.php looks like this:
Yes , my site is also blank . It means my home page is blank
I attempted this trick to remove the extra white space from my files after I had to delete malicious code from all my php pages. Unfortunately, now the main page of my site is just blank.
I am confused, in your post you state to place it above the WP_USE_THEMES definition, and later you say below. I’ve tried it in both places with the same result.
I must say, that I can’t find the place where I say it should be placed below. It should always be placed in the beginning of the file. Just after
< ?phpand beforedefine('WP_USE_THEMES', true);Cheers. Needed this to fix a client site. Worked a charm.
Wow! I just thinking reinstalling my blog and found this post!
Thank you!!!!!!
Really nice,thanks!
Worked like a charm.
Thanks.
Uh, never mind! It fixed itself over night!
Hi Peter,
Thanks for this – this trick worker perfectly in fixing my broken rss feed. Unforunately, it broke my comments feed worse! Before the fix both feeds had the same problem – an extra, blank line before the XML declaration. (Validation in the comments feed showed there was an additional error further down the page, but at least it attempted to validate). Both feeds got through to Google Reader.
Now the feed for posts works fine, but when I try to validate the comments feed, it gives me: “It looks like this is a web page, not a feed. I looked for a feed associated with this page, but couldn’t find one” and an internal server error.
When I revert to the original version of the index.php file, both feeds go back to their original, broken state. Any insight on why this fix might effect my comments feed in this way would be greatly appreciated!
Hi Matt,
I’m glad the trick worked out for you in the matter of fixing your RSS feed. I have never used my own comment feed, but tried to sign up for it in NetNewsWire, my feed reader, and it shows up fine. How are you validating it?
i try this method but this method redirect my feed to igoogle
Hello!!! this method didnt work for me… do you know any other?
No, unfortunately I do not know any other method for removing the blank lines, other than looking through all your theme files (especially functions.php) and removing them manually.
Are you sure you uploaded wejnswpwhitespacefix.php into your root folder? That is, not your theme’s root, but the root of the WordPress installation.
Make sure it’s right after define(‘WP_USE_THEMES’, true); that you include this:
include("wejnswpwhitespacefix.php");.Let me know how it works out for you.