2

I created a child theme from twentythirteen and it worked like it should. Then I made a copy of the parent theme's header.php. As soon as I created it, the outputted HTML got broken. All tags that are supposed to go in the <head>-tag instead shows up in the <body>-tag, and the <head> is empty. This happens even if the content of header.php in my child theme is exactly the same as the original.

The same happens if I create a new functions.php in my child theme. Even though it only contains this:

<?php
?>

or is totally empty. If I remove the file, the head content get put in the correct place again.

EDIT: The actual source code is actually correct (if I choose "view source"), the error only shows up in inspector mode in Chrome and IE, but not in Firefox's inspector.

  • 1
    Are you sure this is not a case of two <head> tags being written to the page? Sometimes inspect element on your browser will show a mangled HTML tree where it tried to fix errors. show source should give an actual view of what was written. – Twifty Dec 5 '13 at 9:59
  • Yes, I have now checked it in IE, Chrome and FF and the actual source code is correct when I open "view source", but the error shows up in inspector mode in Chrome and IE, but not in FF... – stinaq Dec 5 '13 at 10:45
  • Without the code this is going to be hard to answer, but you've done something wrong in the child theme or you have a very very badly behaved plugin. What are you using to edit the files? What software? – s_ha_dum Dec 5 '13 at 14:05
  • Could you set up live example of the issue? That would be helpful since otherwise it's hard to guess what exactly is wrong with it from dev tools point of view. – Rarst Dec 5 '13 at 20:35
0

I used to have this problem once, for me it happened because I used the wrong encoding. I also had the right sourcecode but it came out all wrong on the actual page.

Try setting your editors settings to "UTF-8 without BOM" because the BOM is what seems to be causing that error.

Sometimes it also happens if you copy and paste text from somewhere and it copies some invisible characters. Try typing the stuff yourself, and it might just work.

(there's more people with the same problem, e.g. https://stackoverflow.com/questions/17566119/why-are-tag-title-meta-tag-going-from-head-to-body-tag-automatically

https://stackoverflow.com/questions/14646223/header-appearing-in-body-tag-wordpress and what I said above usually worked for them to fix it)

  • I think this might be right! I actually recreated the whole project, copied the exact same code and now it works. The only difference was that the second time I did it in Sublime instead of Visual Studio. I hod no idea why it worked then, but this might be the reason. Thank you!! – stinaq Dec 15 '13 at 20:12

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.