• joker1234

    (@joker1234)


    I tried to put show_admin_bar(false); anywhere but it doesn’t work. Is there something I must do before?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator bcworkz

    (@bcworkz)

    It should work on the front end. As of 3.3 you cannot remove it from the back end any more. If it really bothers you, you can hide it with CSS.

    Thread Starter joker1234

    (@joker1234)

    It doesn’t work anywhere.

    andrei1709

    (@andrei1709)

    go to /wp-includes/css/admin-bar.min.css

    and add this:

    #wpadminbar {
      display: none;
    }

    the exact CSS path is html body.home div#wpadminbar.no-grav

    Thread Starter joker1234

    (@joker1234)

    Yes, but this leaves a gap of 32px on the top of the body.

    Moderator bcworkz

    (@bcworkz)

    You really shouldn’t alter core files like that, especially when there is a clean alternative. Try this:

    add_action('wp_enqueue_scripts', 'jkr_hide_bar', 99 );
    add_action('admin_enqueue_scripts', 'jkr_hide_bar', 99 );
    function jkr_hide_bar() {
       if( is_user_logged_in()) echo '<style type="text/css">
          #wpadminbar { display: none; }
          body { margin-top: -32px !important; }
       </style>';
    }

    The code goes in functions.php of your theme, or preferably your child theme.

    Thread Starter joker1234

    (@joker1234)

    Great, thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘show_admin_bar(false); doesn't work’ is closed to new replies.