这可能不是正确的方法,但这在测试时对我有效。您可以使用这些组合删除工具栏(管理栏)中的所有链接,然后使用css隐藏空工具栏:
function remove_admin_bar_links() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu(\'wp-logo\'); // Remove the WordPress logo
$wp_admin_bar->remove_menu(\'about\'); // Remove the about WordPress link
$wp_admin_bar->remove_menu(\'wporg\'); // Remove the WordPress.org link
$wp_admin_bar->remove_menu(\'documentation\'); // Remove the WordPress documentation link
$wp_admin_bar->remove_menu(\'support-forums\'); // Remove the support forums link
$wp_admin_bar->remove_menu(\'feedback\'); // Remove the feedback link
$wp_admin_bar->remove_menu(\'site-name\'); // Remove the site name menu
$wp_admin_bar->remove_menu(\'view-site\'); // Remove the view site link
$wp_admin_bar->remove_menu(\'updates\'); // Remove the updates link
$wp_admin_bar->remove_menu(\'comments\'); // Remove the comments link
$wp_admin_bar->remove_menu(\'new-content\'); // Remove the content link
$wp_admin_bar->remove_menu(\'w3tc\'); // If you use w3 total cache remove the performance link
$wp_admin_bar->remove_menu(\'my-account\'); // Remove the user details tab
}
add_action( \'wp_before_admin_bar_render\', \'remove_admin_bar_links\' );
function hide_admin_bar() { ?>
<style type="text/css">
#wpadminbar {
display: none;
}
</style>
<?php }
// on backend area
add_action( \'admin_head\', \'hide_admin_bar\' );
// on frontend area
add_action( \'wp_head\', \'hide_admin_bar\' );
有关更多详细信息,请阅读此
link 输出如下屏幕截图: