WordPress 3.1 Admin Bar Upgrade Issues

Well, WordPress 3.1 has been out in the wild for hours now.  I’m seeing the support requests trickle in, and there is already a very common issue.  A strange white gap at the top of the page where the admin bar should be.  Let’s fix that, or conversely, if you have the admin bar and hate it, let’s get rid of it!

First up, the mysterious missing admin bar, leaving just a gap at the top of your page.  Now remember, the admin bar only shows when you are logged in.  But if you are logged in and just see a blank space with no admin bar, chances are you are missing your wp_footer call.  Simple fix, add it in footer.php on the line above your closing body tag, so your footer.php should end like:

          <?php wp_footer(); ?>

On the flip side of this problem is the wp_head call. This may surprise you, but that one goes up in your header.php file! Take a look, it should be right before the closing heade tag, or real close. It may not be at the very bottom of your header.php file itself, as often there is body content in your header. Your header image, your navigation, etc. But somewhere in your header.php file you should see:

<?php wp_head(); ?>

I’m amazed this is affecting so many people. That wp_footer and wp_head calls are vital for so many things. Anyway, get that in there and you should be all set. Now what if you hate the admin bar. Well for one, you can set it up in your user profile page. Turning it on or off for the front or back end. Or you can drop this into functions.php to kill it altogether:

remove_action('init', 'wp_admin_bar_init');

I’ve also seen this code for removing the admin bar (I trust the author of this solution, so I’d try this one first):

/* Disable the Admin Bar. */
add_filter( 'show_admin_bar', '__return_false' );

Either way it gets added to functions.php. (or mu-plugins for site wide on multisite, you’ll remember that from this article)

And there you have it. 2 Admin Bar problems resolved! If you have other problems with the admin bar, or found this topic looking for general problems with a 3.1 upgrade, please check out this link on the forums. It’s a master list being kept of problems and solutions.

68 Replies to “WordPress 3.1 Admin Bar Upgrade Issues”

  1. Neat tips, I had a problem just like the White band on a new site and discovered the I never included the wp_footer hook, both wp_footer and the wp_header are vital if you want your themes to function properly

    1. Well, thanks for your input. That article has the same info. Maybe less of it. And mine was written far earlier. Well before that article you linked to. Actually mine was written very shortly after the release of WP 3.1. I was trying to get accurate information out as quickly as possible once I saw a problem.

  2. Just found out you can also use the native WordPress show_admin_bar() function in your theme’s functions.php to disable the admin bar.

    // or

      1. Yes it is similar. The filter returns the function false, just as the function does when you set it to false. Just saying you don’t need the filter because the function itself only accepts true or false. My knowledge of filters is also pretty rudimentary so either way is good I suppose.

  3. Thanks for this! Where exactly do you put this in the function.php?
    /* Disable the Admin Bar. */
    add_filter( ‘show_admin_bar’, ‘__return_false’ );

    Thanks! Great article!

    1. It can really go anywhere. Your functions.php file will start out most likely with an opening php tag. Anywhere after that is fine. Hopefully your file is laid out well enough that you can see each individual function. You want to make sure you aren’t adding new code in the middle of a function. You can insert a blank line under the opening php tag if you like, or between any function and just paste that code on it’s own line.

      1. Thanks Rev! Really appreciate your quick response! I don’t like to just put things anywhere anymore…I know what happens!

        1. Yes, functions.php especially can be sensitive file! But really, there are just a few guidelines. The opening php tag must be the very first thing. Any new code you add must be inside the php tag. You can’t nest php tags (like have an opening php tag, and then another opening php tag, without a closing one). And you don’t want to put anything into the middle of a function. It takes a bit to get used to, but once you get the hang of it, editing the files gets easier. My #1 rule, always make sure you have a file backup before playing around in there! Just to be safe.

          1. Yea, I have to go back and redo it! I entered it, renamed the old file for a back up, and the edited file errored my site. Lucky I renamed the original!
            I need to read more up on it!

  4. Wow, thanks for this article. I was shocked to learn that I was missing that vital code in my footer.php file. All my other themes are fine, so I must have had a brain fart the day I wrote this one.

  5. I’m having a weird problem with the Admin Bar. I have both Dashboard and when Viewing site checked. It only shows in the Dashboard but not on the site. There’s no white gap and footer.php has

    What else could be causing this? It can’t be the theme as I’ve signed in on another site with the same theme and that one displays the Admin bar?

    1. Does your header.php also have the wp_head? It could be a plugin conflict, in which case you would need to test your site with all plugins inactive. And it very well could be the theme. The only way to conclusively say it’s not the theme is to test. Perhaps the one you saw had been fixed. It’s basic troubleshooting 101, test site with twentyten theme and plugins inactive.

        1. Well that is a strange problem. I’m not even sure what to do from here. I personally would turn it off in the options, save, and then turn back on and save. Then when visiting your site, check your source code (view source from within your browser) and see if you are getting any output. You should have some css referring to wpadminbar in your header, and also some output in your footer.

        2. This has happened to me a few times. In my case the cause is always that I was developing the site under a directory – and then I move it to root to launch. But when I move it to root – the admin bar goes away. This is most likely because the cookie on whether to show that admin bar or not is stored to the directory I originally had the site showing under. Deleting cookies, logging out, (and then logging back in) usually fixes this problem.

    1. Have you looked into the first 2 things mentioned in this article? Normally that happens when the wp_footer call is missing from footer.php. Make sure your theme has both wp_head in the header and wp_footer in the footer as talked about in the article. That’s the most common thing. If that doesn’t work, deactivate all plugins and test. The next most common problem is a plugin conflict. And finally switch to the twentyten theme and test to see if there is a theme conflict. One of those methods should work for you, but I really think its related to a missing bit of code in your header or footer.

  6. Thank you! Thank you! You have no idea how much I’ve searched the web to find this answer–and it turned out to be so simple!

  7. I have the same problem, that is, my admin bar shows as an unordered list at bottom of site, BUT… I have this in my header.php

    <head profile="http://gmpg.org/xfn/11">
    <title><?php wp_title('&laquo;', true, 'right'); ?> <?php bloginfo('name'); ?></title>
    <?php include "meta.php"; ?>
    <?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?>
    <?php wp_head(); ?>

    and this in footer.php

    <?php wp_footer(); ?>

    So… what’s wrong?

    1. Since you have the usual suspect ruled out, the next step is to test theme compatibility. Switch to twentyeleven and test. Admin bar still off? Do the same with plugins. BUt if, upon switching themes, the admin bar comes back, you have to narrow things down further, possibly commenting out scripts or functions 1 at a time and testing for conflict (It should be easy to pick things out which may be highly suspect)

      If it is the site you linked when leaving this comment, there is a good amount of js there which may conflict. I see you also manually link to a jquery in your theme…what version? WP has jQuery built in, so it isn’t necessary to include the library in the theme I wouldn’t think.

  8. Rev. Voodoo, thank you very much for posting the information about including the wp_footer call above the closing body tag in the footer.php file. I searched for over an hour and came across a post you commented on. I have noticed that you have commented on several wp related things all across the web sharing your vast wisdom and insight.

    Thank you for taking the time to educate WordPress users.

  9. This helped me out a lot, so thanks! I couldn’t figure out why my purchased template didn’t have the admin bar — turns out they were using the remove code above, so I was able to do a CTRL+F to find it and remove it. Saved me the hassle of contacting the template creator.

    Thanks again!

  10. Sorry to resurrect this one, but I’m having the same problem (no blank line, but no toolbar either, even though it is enabled in my profile) with wp3.4, having redirected my “production” url to point to my new site. It all worked fine with my dev url pointing to it. Using twentyten theme, have changed to twentyeleven and back again. Have disabled all plugins and reenabled them. The wp_head and wp_footer calls are in place in the header and footer php files.
    I get the impression that I’m not “properly” logged in as an admin somehow.
    I’d be tearing my hair out if I had any left. Any ideas ?

    1. Well, if you have the themes and plugins menus available (in the backend)… you are logged in as admin! I see you are using a child theme… I assume you tested on non-child themes as well? YOu seem to have gone through all the troubleshooting steps. That just leaves the redirection to wonder about. What exactly do you mean by redirection? Did you move your install? All your URLs look like they are coming up correctly, so that is good.

    2. Also, random thing to try, did you regenerate permalinks after the redirection? Simply go to settings->permalinks, and click save – don’t actually make any changes. This resets permalinks and can sort out several odd problems, especially after any sort of move or anything.

  11. Yes sir I have got the wp-admin bar back. I was giving some space on the top of my page so it was not working. Thanks a lot it was really pleasure visiting here. Keep your good work going.

Leave a Reply