So you have been working on your new WordPress theme and all of the sudden either all or some of your scripts and/or styles that normally appear in the
<head> element start appear below the
<body> element. A very frustrating, yet often common, issue that can occur with WordPress. In this WordPress Tutorial post we are going to review two reasons this can occur and how to resolve them.
The most common reason this occurs is for some unknown reason when you saved the file you were working on the encoding type changed. Your files should be saved a UTF8-without-BOM. In most cases your files should normally be saved this way, but if you make a change or copy a file from another location it could lead to a change in the encoding. Not to fret, this is a simple fix.
To resolve the issue simply open the file in Notepad, or the text editor of your choice, go to Save As and change the encoding to UTF8-without-BOM. You may just see an option for UTF8 and UTF8-with-BOM, in this case just choose the UTF-8 encoding type (it is inferred that without-BOM on that type). If you are using an app like Sublime Text to edit your files you can go to File > Save with Encoding and select UTF-8.
If you can’t figure out which file is causing the issue, definitely try at least your header.php and index.php files. They are the likely culprits in this case.
Blank Lines/Extra Characters
Another culprit for this frustrating issue is to have extra blank lines at the beginning, or more commonly the end, of your file. Make sure to delete any unneeded blank lines from the end of your files.
A Combination of Both
In some cases you may find that a combination of both resolutions above will ultimately resolve your problems.
Hopefully one of these two fixes resolves the issue and you are back on your way to developing your new theme.
Note:Improve your site performance and receive phenomenal support at the same time. For discounted hosting services visit Bluehost.com.
For help with WordPress if I can suggest a helpful book that got me started with WordPress development: Professional WordPress: Design and Development
Latest posts by Jeff Mould (see all)
- Laravel 5.4 Redirect after Password Reset Email Sent - September 8, 2017
- How to Fix Laravel 5.2 Token Mismatch Errors - June 30, 2016
- How to Get Sirius XM Deals - May 27, 2016