Created
January 22, 2018 12:37
-
-
Save richerimage/8d1cb0c4c96dd94daee8ae1fa4f001ba to your computer and use it in GitHub Desktop.
Disable Wordpress Admin Bar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Source | |
* https://code.tutsplus.com/articles/how-to-disable-the-admin-bar-in-wordpress-33--wp-23361 | |
*/ | |
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'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment