metinsaylan // rogue developer

How to fix common RSS feed errors in wordpress


Wordpress plugins & themes sometimes may break down your xml structure. XML is so strict that it doesn’t accept any space, tabs or blank lines in it’s first line. In this post i will show you how to easily fix common RSS Problems with wordpress. *** While fixing your RSS Feed, the first thing you will need is a validator. Fortunately we have a great feed validator here. Just enter your feed url to the box and click Validate to see the problems.

Wordpress 3.0.4 users, try this option first: I found a blank line at the end of template-loader.php file that comes with the installation. When you try to validate your feed you will see an error like this: XML Parsing Error: XML or text declaration not at start of entity. You can download it’s fixed version here: [download id=20] Rename this file to template-loader.php (If you can’t rename it open with notepad and save as template-loader.php) and then upload this file to WORDPRESS_ROOT/wp-includes/ folder. Overwrite the file on your server. Re-validate your feed to see if it is fixed. If not fixed, we can go on with other options..

Common problems are caused by plugins & themes that output spaces or text when loaded. Those can be eliminated with one easy step. Just download this plugin, install and run it on your wordpress site to fix those type of errors. It will simply search for spaces and new lines at the end of php files. It will also edit your wp-blog-header.php to ignore those spaces if there is any. Here is the sample edit it does when you run:

[php title=”/wp-blog-header.php” highlight=”4,6”]<?php if ( !isset($wp_did_header) ) { $wp_did_header = true; ob_start(); // Edit : Fix RSS Error require_once( dirname(FILE) . ‘/wp-load.php’ ); ob_end_clean(); // Edit : Fix RSS Error wp(); require_once( ABSPATH . WPINC . ‘/template-loader.php’ ); }

I removed comments and blank lines to make it more readable. At this step you need to revalidate your feed. If you have any cache plugins first you may need to disable or erase cache before you re-validate.

Second option is for php5 users only. If your host is using php5 then you can <a href="">download this file</a> and then upload it to your wordpress root folder. Then put this line right after `&lt;?php` in `index.php`:

[php title="/index.php" highlight="2"]&lt;?php
  include(&quot;wejnswpwhitespacefix.php&quot;); // RSS fix
  define('WP_USE_THEMES', true);

Re-validate your feed to see if it is fixed. If not then you need a php expert to solve it using last option.

Last option - If you are not an expert i do not recommend this option. You need to check every php file for spaces, tabs and new lines after ?> at the end of file. Here is the checking order:

  1. index.php
  2. wp-blog-header.php
  3. template-loader.php
  4. functions.php in your theme folder
  5. Other php files in your plugin folder

Hope you liked this post. You can thank me below if it helped ;)

Search How to fix common RSS feed errors in wordpress on Google