No More Invalid RSS

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.

Share, share, share!

Did you like this article? Please share it with your friends:
  • Digg
  • del.icio.us
  • Facebook
  • StumbleUpon
  • Technorati
  • Twitter
  • email

Related posts:

  1. Welcome to Stiern.com
  2. How to Use Directions with Google Maps API V3
  3. Installing Concrete5 locally on Mac OS X

14 comments so far

Add one yourself

  1. Tracy says:

    Where do I insert your code to fix?

    My index.php looks like this:

  2. Farzad says:

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

  3. James E. says:

    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.

    • Peter says:

      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);

  4. Jon says:

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

  5. Zil-el-Saif says:

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

  6. Mark says:

    Worked like a charm.

    Thanks.

  7. mattyoungmark says:

    Uh, never mind! It fixed itself over night!

  8. mattyoungmark says:

    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!

    • Peter says:

      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?

  9. Bio War says:

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

  10. Bio War says:

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

    • Peter says:

      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 & Pingbacks