WordPress at Your Fingertips

show_admin_bar() WP 3.1.0

Allows you to disable the "Toolbar" (Admin Bar). Technically, the function enables/disables "Admin Bar" for the front-end. You cannot turn it off in Admin-panel.

You can call this function at an early stage, even before plugins loaded. Normally the function used in functions.php file. There is no need to call the function during the init event.

This can be called immediately upon plugin load. It does not need to be called from a function hooked to the init action.

Note: "Admin Bar" was renamed with "Toolbar" since WordPress Version 3.3.

There's also a filter that allows to turn OFF/ON the Toolbar, and it has higher priority than this function:

add_filter('show_admin_bar', '__return_false'); // turn off
add_filter('show_admin_bar', '__return_true');  // turn on
  1. Until version 3.3, this function affects the Admin Bar in the dashboard.
  2. For versions below 3.3 you may want to turn off the Admin Bar for the frontend only. Use this code:

    add_filter('show_admin_bar', '__return_false');

No Hooks.


null. Nothing.


show_admin_bar( $show );
$show(true|false) (required)
Whether to allow the admin bar to show.


#1 Turn off Toolbar completely

Suppose you want to turn off the "Admin Bar" on the frontend completely. To do this, paste the following code into the functions.php theme file:

show_admin_bar( false );

#2 Turn off the Toolbar for everyone except an administrator

Use current_user_can() for that:

if ( ! current_user_can( 'manage_options' ) ) {
	show_admin_bar( false );


  • Global. true|false. $show_admin_bar


Since 3.1.0 Introduced.

Code of show_admin_bar() WP 5.8.1

function show_admin_bar( $show ) {
	global $show_admin_bar;
	$show_admin_bar = (bool) $show;

toolbar (admin bar)


No comments
    Log In