WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] 3.1 Update Causing 28px top-spacing in html body (28 posts)

  1. looknostyle
    Member
    Posted 3 years ago #

    After updating my wordpress it started cause some unusual body spacing. When I view page source I see some unusual coding, trouble is I dont know which file it's located in to delete it:

    http://prepjerks.com/tester/

    <style type="text/css" media="print">#wpadminbar { display:none; }</style>
    <style type="text/css">
    html { margin-top: 28px !important; }
    * html body { margin-top: 28px !important; }
    </style>

    There's the css that shouldn't be in the index but I dont know how it got there or how to get rid of it. It's magically appeared after the update, any suggestions?

  2. christopherross
    Member
    Posted 3 years ago #

    @looknostyle, that would be the new admin bar for wp 3.1

    If it's acting up on your site, open your user profile (Users > Your Profile) and uncheck the 'Show on Front' option to make it disappear.

    Chris

  3. looknostyle
    Member
    Posted 3 years ago #

    thanks you!

  4. wambamboo
    Member
    Posted 3 years ago #

    I've unchecked that option but am still getting the 28px margin at the top of my site. Weird!

    The Disable Admin Bar plugin's not doing it for me either. Double weird.

  5. MobilePhoneFinder
    Member
    Posted 3 years ago #

    Try adding this to your theme's functions.php. This fixed the issue on my site:

    function my_function_admin_bar(){ return false; }
    add_filter( 'show_admin_bar' , 'my_function_admin_bar');

    Essentially it overrides the hook to show_admin_bar with a custom function, which returns false, and as a result remove the admin bar altogether.

    Not sure if you're after such an extreme solution but it worked for me. I didn't need the admin bar anyway anyway as most of my site functions are already taken care of within my Firefox bookmarks.

    Good luck!

  6. MundoCaco
    Member
    Posted 3 years ago #

    @christopherross thanks!

  7. lizajane85
    Member
    Posted 3 years ago #

    Thanks @MobilePhoneFinder. That worked!

  8. stevelockridge
    Member
    Posted 3 years ago #

    This top-margin error was only affecting Firefox 3.6 on Windows. IE8 (Windows), FF (Mac), and Safari (Mac) rendered correctly. I added the function listed above and it corrected the problem. Thanks!

  9. Avinash Bhageloe
    Member
    Posted 3 years ago #

    Thanx a lot :)

  10. bkdabrowski
    Member
    Posted 3 years ago #

    So how do you eliminate the spacing but keep the admin bar? I went into the admin-bar.php file and removed the !important style, but the spacing still showed up when not logged in.

    This is the worst element of this whole thing. It shouldn't be so hard to butt your header up against the top of the viewport.

  11. First up, no one ever edit core, please ;) Also posting in resolved topics makes it hard for us to know you need help. We assume if it's resolved, you're done.

    If your site is munging the admin bar layout, check that you have BOTH wp_head() and wp_footer() in your theme. You need both :D

    If that doesn't help, you can put this in your functions.php:

    function my_admin_css() {
            if ( is_user_logged_in() ) {
            ?>
            <style type="text/css">
    [PUT YOUR CSS FOR LOGGED IN USERS HERE!]
            </style>
            <?php }
    }
    add_action('wp_head', 'my_admin_css');

    If you want to change it for non-logged in users, it's !is_user_logged_in

  12. bkdabrowski
    Member
    Posted 3 years ago #

    Sorry. Didn't realize it was closed. I have been (with great frustration) trying to find the 28px for an hour, then I couldn't log into WP to look into it since the passwords were changed and the reset password still wasn't letting me in.

    wp_header() and wp_footer() are there, since it's still twenty eleven. I'll look into your suggestion; however right now I'm going with, "If you can't beat them, join them," and working the gap into the design.

  13. sagive
    Member
    Posted 3 years ago #

    Thanks MobilePhoneFinder :)

    That did the trick for me

  14. Ben Cao
    Member
    Posted 3 years ago #

    thanks

    Ipstenu,the function is very good yet!

  15. Khaled Hakim
    Member
    Posted 3 years ago #

    Just wanted to confirm that the solution provided above fixed my issue. Note that the issue was browser-dependent. On chrome I had no issues at all while on firefox the margin problem was driving me nuts.

    Opened the functions.php file found in wp-content/themes/twentyten... added the following code tot he bottom of the file:

    function my_function_admin_bar(){ return false; }
    add_filter( 'show_admin_bar' , 'my_function_admin_bar');

    Margin issue resolved pour moi.

    Cheers.

  16. ngwkoop
    Member
    Posted 3 years ago #

    Just for everyone's information, I was having some of the symptoms mentioned above (margin and such), but I was also having a LOT of Javascript errors.

    As our Half-Elf Support Rogue mentioned, YOUR THEME ABSOLUTELY HAS TO HAVE wp_head() and wp_footer(), or you will get admin bar, margin, and javascript errors everywhere.

    I downloaded a cheap theme which didn't properly do this. When I added my head and foot, all was good!

    The "display admin bar" settings don't really matter, as they will function correctly with a correct head and foot.

  17. Dunhamzzz
    Member
    Posted 3 years ago #

    There's no need to create a custom function to return false, WP has on built in call '__return_false. ie:

    add_filter( 'show_admin_bar', '__return_false' );
    It has to run as early as possible to remove the padding, I had it in the init action, but it only removed the admin bar, not the margin.

  18. Zack Katz
    Member
    Posted 3 years ago #

    Actually, you can keep the admin bar intact while removing the CSS style by adding this:
    remove_action('wp_head', '_admin_bar_bump_cb');

  19. muldy
    Member
    Posted 2 years ago #

    Go to /wp-includes/admin-bar.php, and search on 383 line css code, and remove it!!!!

  20. Kruncher
    Member
    Posted 2 years ago #

    I needed to keep the admin bar but remove the 28px margin so I followed Zack's advice by adding the following to my custom theme 'functions.php' script:

    add_action('get_header', 'my_filter_head');
    
    function my_filter_head() {
    	remove_action('wp_head', '_admin_bar_bump_cb');
    }

    Works perfectly!

  21. luckykind
    Member
    Posted 2 years ago #

    @Zack & @Kruncher... Thx! you stopped the hour and a half of madness in it's tracks... ;)

  22. kylesalonga
    Member
    Posted 2 years ago #

    Thanks MobilePhoneFinder did the trick!

  23. terryfic
    Member
    Posted 2 years ago #

    Muldy - Thank you!!! This was dogging me all morning; your solution is simple and quick. Actually, I changed the value to 0 to keep the line intact.

  24. jamie3d
    Member
    Posted 2 years ago #

    Thanks @Zack & @Kruncher !
    That's exactly what I was after.

  25. smjustin
    Member
    Posted 2 years ago #


  26. esmi
    Forum Moderator
    Posted 2 years ago #

    No! Never edit WordPress core files!

  27. raneesh
    Member
    Posted 2 years ago #

    thanks

  28. hoolianv
    Member
    Posted 2 years ago #

    @MobilePhoneFinder That worked!

Topic Closed

This topic has been closed to new replies.

About this Topic