Home » Hooks » show_admin_bar

The show_admin_bar hook is a WordPress filter that controls the display of the admin bar on the front-end of your website. By default, the admin bar is only visible for logged-in users with the permissions to edit posts and pages. However, this hook allows developers to modify this behavior by changing the value of the filter.

Using the show_admin_bar hook, developers can disable the admin bar for all users or enable it for non-logged-in users. Additionally, they can also customize the appearance of the admin bar by adding custom CSS styles.

Here’s an example usage code for the show_admin_bar hook:

function custom_admin_bar_display( $show_admin_bar ) {
    if ( ! is_admin() ) {
        $show_admin_bar = false; // Disable the admin bar for non-admin users
    return $show_admin_bar;
add_filter( 'show_admin_bar', 'custom_admin_bar_display' );

In this example, we’re using the add_filter() function to add a custom filter to the show_admin_bar hook. The custom_admin_bar_display function is then used to modify the value of the filter. In this case, we’re disabling the admin bar for non-admin users by setting the value of the $show_admin_bar variable to false.

Learn More on

Register an account to save your snippets or go Pro to get more features.