WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] remove space from top of source code (5 posts)

  1. micasuh
    Member
    Posted 4 years ago #

    When I click on view source, every page has an extra line break before the doctype!

    I've deactivated all plugins. Doesn't help.
    I've selectively deleted code. Doesn't help.
    I've switched to a completely different theme all together. No top line break in source code.
    I've deleted CSS and JS file code. Doesn't help.

    Is this a problem with my template or is it something deeper?

  2. @mercime
    Volunteer Moderator
    Posted 4 years ago #

    "I've switched to a completely different theme all together. No top line break in source code."

    I saw it happen once with an advanced theme which included some theme options at top of header.php. What theme are you using or Site URL?

  3. micasuh
    Member
    Posted 4 years ago #

    Well, I resolved my problem!

    What I did not know and could not find any information about is that it's not good to have any spaces in functions.php. I've seen talk about this with other people but it wasn't specific.

    If there is any space between php requests, that can break the feed since somehow it inserts a space in the templates after rendering.

    For example, if you have several php requests that are opened and closed, they should be right next to each other. Such as this:

    <?php foo ?>
    <?php foo ?>

    If it looks like this:

    <?php foo ?>
    [extra line break here]
    <?php foo ?>

    it'll break because of the extra line break in the middle of the php requests.

    So always put php requests right next to each other. Your theme and feed will thank you!

  4. @mercime
    Volunteer Moderator
    Posted 4 years ago #

    Good for you and thanks for sharing your solution.

  5. leesal
    Member
    Posted 3 years ago #

    Thanks micasuh.

    I was having the same issue with mysterious white space above the doctype. This fixed it.

    It also seems to have fixed an issue I was having with not being able to edit widgets in the admin area.

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic