Get Rid of Top Margin on Custom WordPress Themes

I found out from experience and from browsing the internet that a lot of people are having issues with a mysterious 28px margin appearing at the top of their blog when developing a custom theme or a page template for an existing theme. This frivolous bug has the potential for people to start looking for other unlimited wordpress hosting websites to try to change their current webhosting wordpress website, and assimilate if that does the trick.

The Problem

The problem is that a built-in core WordPress function inserts an inline style into the head of your webpage with a top-margin set to 28 pix.

The Reason

The reason for the 28px top margin is to make room for the WordPress top admin bar, so you may have noticed that this margin is only there if you are logged in.

The Cause

the cause of the inline style is the wp_head function. It happens most of the time when you do not call the wp_footer function at the bottom of the HTML markup, just before the closing body tag.

The Solution

Therefore, the most common solution to make this go away, is to simply make sure to include the wp_footer function in your theme’s files just before the closing body tag. It can be inserted in either the page.php file or the footer.php file. It can also be inserted in any other page template file as long as it is directly before the ending body tag.

Leave a Reply

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