WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Unwanted margin resulting from wp_head (5 posts)

  1. mirshafie
    Member
    Posted 3 years ago #

    Hello folks. I have suddenly noticed a strange problem with a theme that I'm developing.

    The background image for the theme is supposed to be positioned at the top of the page, but there is a gap of about 25 px from the top of page to where the background image starts. (Background color begins at the top.)

    I've tried removing everything else from my theme code and stylesheet, and have come to the conclusion that there's something off with wp_head. As soon as I remove the call for wp_head in header.php, the gap to the background image disappears.

    Now, my theme is very simple and for a specific purpose, so I don't think that I really need wp_head. But I would still like to know what is causing the problem, so I don't go on making shaky themes.

    Any input would be greatly appreciated.

  2. esmi
    Forum Moderator
    Posted 3 years ago #

    but there is a gap of about 25 px from the top of page to where the background image starts.

    I think you'll find it's 28px and that it's due to the Admin bar.

    Do I really need wp_head in my header?

    Absolutely! It's required by WordPress itself and many plugins.

  3. mirshafie
    Member
    Posted 3 years ago #

    I think you'll find it's 28px and that it's due to the Admin bar.

    I think you're right. Logging out closes the gap. I hadn't really reflected on the fact that the Admin bar was gone.

    Any idea why the content of the Admin bar doesn't show up?

  4. esmi
    Forum Moderator
    Posted 3 years ago #

    Does your theme have a call to <?php wp_footer();?> in footer.php

  5. mirshafie
    Member
    Posted 3 years ago #

    No, and it turned out to be the problem. This was the first theme I built from scratch and I had not realized how important the wp_footer call was.

    My theme works now.

    Thanks for patiently answering this issue again, esmi.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.