I am trying to remove the annoying WP Admin bar css.

<style type="text/css" media="screen">
html { margin-top: 32px !important; }
* html body { margin-top: 32px !important; }
@media screen and ( max-width: 782px ) {
    html { margin-top: 46px !important; }
    * html body { margin-top: 46px !important; }

I have tried (according to other OLD answers):

 * Remove admin bar CSS

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

It does not work.

  • Do you just want to remove the CSS, or the whole admin bar? If you only remove this CSS then the admin bar will overlap the top of the page. – Jacob Peattie Oct 2 '19 at 2:54

Good morning!

This filter should work add_filter('show_admin_bar', '__return_false'); right from the wordpress codex.

Alternatively, you can disable it from specific users.enter image description here


You can disable it for everybody :

add_filter('show_admin_bar', '__return_false');

or do conditionally hide it :

 add_filter('show_admin_bar', 'my_function_to_hide_it');
function my_function_to_hide_it(){
// condition and return true or false 

All details there : https://codex.wordpress.org/Function_Reference/show_admin_bar

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.