Override Admin Bar CSS

I’m trying to override the CSS injection from wp_head, more specifically the _admin_bar_bump_cb function from admin-bar.php… In the past I’ve simply used the following in my functions.php:

function admin_bar_css() {
    remove_action('wp_head', '_admin_bar_bump_cb');
add_action('admin_bar_init', 'admin_bar_css');

However this doesn’t seem to work in roots, unless I’m missing something? I tried placing this in the lib/custom.php file, also tried increasing the queue position of my add_action() but nothing took.

I understand the roots theme wrapper uses a different method for constructing pages compared to stock WP, but surely this should still work…? Anyone know what’s going wrong here?


The wrapper will not affect this. Are you using the MP6 plugin by any chance?

Thanks for the wrapper confirmation, I didn’t think it was likely (hence me trying it first), but it’s good to know.

Never heard of MP6 before, so that would be a no. I do two other ‘admin’ related plugins, however my snippet doesn’t work even with all plugins disabled (listed below for reference).

  • Adminimize (1.8.4)
  • Codepress Admin Columns (2.1.0)
  • Easy Image Gallery (1.0.4)
  • The Events Calendar (3.2)

I should also note here that this snippet does work with the default Twenty Thirteen theme with all these plugins enabled.

MP6 is the development plugin for 3.8’s new dashboard.

I’ve tried your script locally and it seems to be working as intended. Have you disabled any caching plugins?

Isn’t 3.8 still in testing though? Either way, I’m currently running WP 3.7.1. (:

If it helps at all, I’ve just pushed my theme in it’s current state to GitHub (link), so if you don’t mind having a look, maybe you might see something I’m missing?

In your repo you are hooking the function to get_header instead of admin_bar_init. It should work with the latter.

You’re right, 3.8 is in development and due December 12th. Most of the changes to WordPress core are now being developed as plugins for earlier versions. MP6 is an example of this and is pretty popular, which is why I asked if you were using it; it has its own CSS that won’t be removed by your code.


Hmmm… I’m pretty sure hooking in to get_header should still work with roots, but I will most definitely try that. It’s past 1am this side of the world though, need some sleep before my day job. (:

Thanks for the help and the info, I’ll leave feedback after I’ve tried hooking into admin_bar_init.

You’re a ninja Foxaii, thanks very much… Still a bit confused by why the admin_bar_init link on this WP Codex page doesn’t exist, but I’ll go digging for more info on that later.

For now though, that change works perfectly. (:

1 Like