I've a strange problem with an Autofocus theme.

In my templates file, header.php, I've a code like this (and is correct)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

When I look at the source code of the generated HTML, I found something like this

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

The extra blank lines are breaking my RSS feeds...

Other info:

  • No filters on the content except wpautop
  • functions.php doesn't do anything on the content
  • Plugins All In One Seo, WP Stats, Smiley Remover, SEO Friendly images

Any clues?

  • 2
    I'll go out on a limb and say this is a plugin. After taking a look at the theme, it doesn't do anything before the doctype tag is printed. Plugins are loaded before Themes, so jjeaton's answer is the right course of action. – Jeff Sebring Jul 28 '11 at 5:00

the_content doesn't affect the DOCTYPE and <html> tags, only the post/page content.

One of your plugins, or something else in the theme is either throwing an error, or is printing something earlier than it should.

Have you tried:

  • Disabling each plugin one by one and see when it is fixed.
  • Editing wp-config.php and adding define( 'WP_DEBUG', true ); to look for errors
  • Got it! But not one plugin, but 4 plugins. That was the first time for me! I suspect a mix of outdated wp and plugins... upgraded everything. But you got it right! +1 – keatch Aug 10 '11 at 9:56
  • @keatch glad I was able to help! – jjeaton Aug 10 '11 at 17:32

I believe the problem is that there are not any <?php opening tags in your header.php so the space is probably coming from your templates that call <?php get_header(); ?>

Try adding a commented out header like so:

 * The Header for our theme.
 * Displays all of the <head> section 
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

It's also possible that you have windows line endings which sometimes get parsed as a dbl line ending adding an extra space to each line.

  • Partially right, but that was not the case. – keatch Aug 10 '11 at 9:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.