How To Remove Margin Top Admin Bar Css In WordPress

How To Remove Margin Top Admin Bar Css In WordPress

How to remove margin top admin bar css in wordpress ? or how to disable margin top css when user login in wordpress ? You can do it by add this code to your theme’sfunctions.php file.

Remove admin bar CSS

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

It will disable margin top inline styles but admin bar will be still available. If you want disable admin bar using code:

Disable admin bar

add_filter('show_admin_bar', '__return_false');

Or:

remove_action( 'wp_footer', 'wp_admin_bar_render', 1000)

Override wordpress admin bar CSS

function remove_admin_bar_style_frontend() {
  echo '<style type="text/css" media="screen">
  html { margin-top: 10px !important; }
  </style>';
 }
add_filter('wp_head','remove_admin_bar_style_frontend', 100);

Comments

comments

Share