Put IT in High Gear – Engage!

WordPress RSS Feed Output Error

April 15th, 2010 by engage

wordpressmu Wordpress RSS Feed Output ErrorEngage has had a Blog site for a few years now and everything has been fine.  We started off with the original WordPress and then in 2008 upgraded to WordPressMU so we could offer Blogs to our customers as a part of a total ecommerce package.  In 2009 we started integrating WordPress in with CRM in some of our xRM projects. 

Last week one of our employees mentioned that their Linkedin account was no longer displaying their RSS feed from the Blog in their profile.  Our FeedBurner links were working as they should.  Then someone else said that they couldn’t sign up for our RSS feed.  So as we were looking into it further and did some searching on the Internet, apparently when we last updated our Blog’s theme we must have placed some extra spaces in some of the template pages.  After we searched some more we found a great post that helped solve the issue. 

All we had to do was insert some additional code to clean up the extra spaces.

The common error is:

XML Parsing Error: XML or text declaration not at start of entity

Or, if you are validating a page using the w3 validator:

XML Parsing Error: XML declaration allowed only at the start of the document

This means that before the < character there are unwanted characters that need to be eliminated (also white spaces) for a clean and correct XML declaration.

The two files we needed to edit are  wp-includes/feed-rss2.php and wp-includes/feed-rss2-comments.php

open the files with a text editor and insert the following code after this section:

header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
$more = 1;

INSERT:

$out = ob_get_contents();
$out = str_replace(array("\n", "\r", "\t", " "), "", $input);
ob_end_clean();

Save an close both files and test.

Please let us know if that helps or if you have found a better way of resolving the error.

No related posts.

blog comments powered by Disqus