Removing admin bar from wordpress dashboard

if (!function_exists('disableAdminBar')) {

    function disableAdminBar(){

    remove_action( 'admin_footer', 'wp_admin_bar_render', 1000 );

    function remove_admin_bar_style_backend() {
      echo '<style>body.admin-bar #wpcontent, body.admin-bar #adminmenu { padding-top: 0px !important; }</style>';
    }

    add_filter('admin_head','remove_admin_bar_style_backend');

  }

}

add_filter('admin_head','remove_admin_bar_style_backend');

Source: http://wp.tutsplus.com/tutorials/how-to-disable-the-admin-bar-in-wordpress-3-3/

OR, for both front and back end…

if (!function_exists('disableAdminBar')) {

    function disableAdminBar(){

    remove_action( 'admin_footer', 'wp_admin_bar_render', 1000 ); // for the admin page
    remove_action( 'wp_footer', 'wp_admin_bar_render', 1000 ); // for the front end

    function remove_admin_bar_style_backend() {  // css override for the admin page
      echo '<style>body.admin-bar #wpcontent, body.admin-bar #adminmenu { padding-top: 0px !important; }</style>';
    }

    add_filter('admin_head','remove_admin_bar_style_backend');

    function remove_admin_bar_style_frontend() { // css override for the frontend
      echo '<style type="text/css" media="screen">
      html { margin-top: 0px !important; }
      * html body { margin-top: 0px !important; }
      </style>';
    }

    add_filter('wp_head','remove_admin_bar_style_frontend', 99);

  }

}

// add_filter('admin_head','remove_admin_bar_style_backend'); // Original version
add_action('init','disableAdminBar'); // New version

THat looks like it should do it…. May I go on record as saying that planning to never update WordPress is a terrible idea. If nothing else, for security reasons.

Some CSS is required in there, or else you end up with a big gap where the bar used to be. NOTE: I’ve not tested this, as I have no need. But that source is normally quite reliable.

Leave a Comment