最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

themes - Blank line before doctype

programmeradmin0浏览0评论

I have a frustrating problem. In the page source, the first line is blank, which causes issues in some browsers.

These are the steps I've taken to try to fix the problem:

  • Gone back to twentythirteen theme
  • renamed plugins folder to oldplugins. Checked in admin and they are all deactivated
  • Made sure there is nothing outside of the php in index.php, header.php
  • cleared out htdoc htaccess

I'm at a loss!

I have a frustrating problem. In the page source, the first line is blank, which causes issues in some browsers.

These are the steps I've taken to try to fix the problem:

  • Gone back to twentythirteen theme
  • renamed plugins folder to oldplugins. Checked in admin and they are all deactivated
  • Made sure there is nothing outside of the php in index.php, header.php
  • cleared out htdoc htaccess

I'm at a loss!

Share Improve this question edited Feb 20, 2014 at 12:00 Chris asked Feb 20, 2014 at 11:52 ChrisChris 4532 gold badges15 silver badges31 bronze badges 3
  • Did you compare all WordPress files to a fresh download if anything differs? – kraftner Commented Feb 20, 2014 at 12:03
  • There's a file called sunrise.php in wp-content. That had an empty line after the closing php so I thought removing that would solve it. It didn't. Interestingly, I put '123' directly after the closing php and that shows up on line 1 of the source, instead of the blank line. – Chris Commented Feb 20, 2014 at 12:18
  • 2 Found it! there was a blank line in wp-config :) – Chris Commented Feb 20, 2014 at 12:20
Add a comment  | 

4 Answers 4

Reset to default 1

In this instance, there was a carriage return after the closing php tag in wp-config.

I know this has already been answered, but in case anyone else runs into it: if there is a ?>\n in any of the included files of the theme's functions.php or in functions.php itself at the very bottom, that can cause it as well.

Great current answers, but worth noting: My extra line breaks were hidden away in /wp-content/mu-plugins/custom-post-types.php where I had setup some Custom Post Types. Once I deleted all characters after the closing ?> and refreshed the front-end, everything works great!

Here is all the step, for each, check if there is not space or empty line before :

  • in the root : check wp-config
  • in your child theme : check functions.php, index.php, header.php
  • in your parent theme : check functions.php, index.php, header.php

Next : deactivate all plugins : check if there is not space or empty line in the html source. If yes, activate your plugins one by one.

Next : Check your functions.php and all the included files. For each, check it.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论