Jason G. Designs

WordPress Themes, Design Tutorials, Linux Themes and more…

Do Not Add HTML Comments to your functions.php File

If you are using WordPress and are either creating themes or using themes, make sure not to use HTML comments (denoted by <!-- information -->) in the functions.php file if you care about Internet Explorer users.

I made this mistake as I was creating the theme for this blog. In the standards compliant browsers Firefox and Chrome, everything rendered correctly. The only issue was functions.php’s HTML comments showing up at the top of each page’s source code. But, in Internet Explorer 7, this broke the website layout! It was because there was information above the doctype declaration.

I decided to use php comments within the php tags as shown below:

<?php 
//php comments
code...
?>

 

In addition, I got rid of any spaces in between each php tag:

<?php
code...
?>
<?php
code...
?>

 

Once these issues are resolved in your theme, everything should render fine in Internet Explorer.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.