Blank line before XML declaration (WordPress)

blank line before xml wordpress

Blank line before XML declaration (WordPress)

The issue

When adding a certain RSS feed to feedburner I received an error message stating “Blank line before XML declaration (WordPress)“.

Check for white space between the <?php php beginning tags and php ending tags  ?>

So I went looking everywhere to remove any white space between the php begin tags and the php end tags.

Problem didn’t got solved.

Sorry

This feed does not validate.

  • line 1, column 1: Blank line before XML declaration [help]

Message

Blank line before XML declaration (WordPress)

Explanation

If an XML declaration (<?xml ... ?>) appears in your feed, it must be the first thing in the feed, before any whitespace.

Unfortunately, with WordPress it seems all too easy for a plugin, a theme, or for your configuration file to contain a blank line. Further compounding this problem, some — but not all — feed readers compensate for this common error, allowing the error to go undetected for quite a while.

Solution

  • PHP also uses a similar notation: <?php ... ?>. Note that the final php ?> should be omitted from all PHP code files—modules, includes, etc. The closing delimiter is optional in PHP (but not in XML), and removing it helps prevent unwanted white space at the end of files which can cause problems with your feeds.
  • Check your wp-rss2.php and wp-atom.php files for blank lines outside of <? and ?> bracketed sections.
  • Check your wp-config.php file for blank lines outside of <? and ?> bracketed sections.
  • Check your theme’s functions.php file for blank lines outside of <? and ?> bracketed sections.
  • One by one, disable plugins and revalidate until you isolate the one causing the problem.

Not clear? Disagree?

You might be able to find help in one of these fine resources.

source : http://www.feedvalidator.org/docs/error/WPBlankLine.html

The fix

Finally I found out that in my functions.php from my child theme I had some white space AFTER the php end tags

Looking like this…

 

After removing empty line 128 and 129 I didn’t receive any error message and my RSS feed was validated.

What not to do

They will often recommend to check the wp-config.php file and the feed-rss2.php file for any white space.

In 99% of the cases that will not be the problem.

When you’re having a child theme or when you created a theme of your own on WordPress the problem will be white space BEFORE or AFTER the start of the php code.

As php code does not show up in html source code. Empty lines before php tags do show up as just a line with no code.

Fixing the empty lines before the php code will solve your problem.

Share this with your friends

Be the first to comment on "Blank line before XML declaration (WordPress)"

Leave a comment

Your email address will not be published.


*