Stiern

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:

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.

29 comments

Leave one yourself

  1. Thanks! its works for me.

  2. Great, it worked :) Thanx very much.

  3. Thanks for the tip! This worked great on one of my sites that I was taking hours to troubleshoot to no avail.

    However this hack broke one of my other sites and I figured out it was the theme that was broken. The theme is Arjuna X. The page encounters a 500 error. Any suggestions?

  4. Thank you!! It worked perfectly!

  5. Great, it worked :) Thanx very much. Cheeeers :D

  6. Cheers for the tip, finally got my Feedburner feed to validate, them pesky blank lines are gone

  7. mate it worked perfectly. You should be covered in gold

  8. thank you very much!!!

  9. Where do I insert your code to fix?

    My index.php looks like this:

  10. Yes , my site is also blank . It means my home page is blank

  11. 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.

    1. 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 < ?php and before define('WP_USE_THEMES', true);

      1. Sorry but I am confused about this. Does this mean that I have to insert the wohle code of the script between the lines <?php nad define (… ?
        This makes no sense to me as Wejn´s code starts with a <?php n also.
        So what is the 1 line of (Wejn´s) code to insert?
        cheers!

  12. Cheers. Needed this to fix a client site. Worked a charm.

  13. Wow! I just thinking reinstalling my blog and found this post!
    Thank you!!!!!!

  14. Worked like a charm.

    Thanks.

  15. mattyoungmark

    May 2, 2009 at 4:22 pm

    Uh, never mind! It fixed itself over night!

  16. mattyoungmark

    May 1, 2009 at 10:34 pm

    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!

    1. 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?

  17. i try this method but this method redirect my feed to igoogle

  18. Hello!!! this method didnt work for me… do you know any other?

    1. 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.

Trackbacks

  1. [...] не помогна. Не се отказах да търся и скоро попаднах на този сайт. Там имаше линк към един друг сайт, който даваше [...]

  2. [...] WordPress 3.0 “Thelonious” has gone live and I have updated the Instructional Technology site, Playing with Technology, Jon Breitenbucher, Orthogonal Creations, The Breitenbuchers and wordpresscore.breietnbucher.net. On my five sites, all hosted on a DreamHost PS, everything went smoothly. I was shocked when this site upgraded without a hitch. I am running 42 plugins on the site and have another 30 or so that are not active. Not a single one had an issue. The only problem I had on the site was with the feed. There is something in the site that is adding blank lines at the head of the feed. A quick Google search and it is fixed. [...]

  3. Erro no Feed do Wordpress - Espaço em branco | Lula Ribeiro

    September 29, 2009 at 7:22 pm

    [...] A tradução da pequena explicação abaixo foi retirada do site No More Invalid CSS. [...]

  4. RSS victory is mine

    May 1, 2009 at 9:20 pm

    [...] up over my problem as I was, but his superior knowledge lead him to find the solution posted on a blog from Denmark. (It seems that whole part of the world has been very kind to me in helping figure this mess [...]