How to customize the Admin bar on top in WordPress

Last updated on 14th February 2023

The WordPress Admin Bar is the bar that appears at the top of your website when you are logged in to the backend of your site. You can customize the WordPress admin bar in several ways:

  1. Remove items from the Admin Bar: You can remove items from the admin bar by using the remove_node method in a custom plugin or in the functions.php file of your theme. Here is an example of how you can remove the "Comments" item:

    function my_admin_bar_render() {
        global $wp_admin_bar;
        $wp_admin_bar->remove_node('comments');
    }
    add_action( 'wp_before_admin_bar_render', 'my_admin_bar_render' );
    
    Add custom items to the admin bar: You can add custom items to the admin bar by using the add_node method in a custom plugin or in the functions.php file of your theme. Here is an example of how you can add a custom item:
    
    function my_admin_bar_items($admin_bar){
        $admin_bar->add_menu( array(
            'id'    => 'custom-item',
            'title' => 'Custom Item',
            'href'  => 'https://www.example.com/',
            'meta'  => array(
                'title' => __('Custom Item'),
            ),
        ));
    }
    add_action('admin_bar_menu', 'my_admin_bar_items', 100);
    
  2. Change the appearance of the admin bar: You can change the appearance of the admin bar by using CSS. You can add the CSS to the custom plugin or to your theme's stylesheet.

  3. Disable the Admin Bar for specific users: You can disable the admin bar for specific users by adding the following code to your custom plugin or to the functions.php file of your theme:

    function my_function_admin_bar(){
        return false;
    }
    add_filter( 'show_admin_bar' , 'my_function_admin_bar');
    

This is just a basic example of how you can customize the WordPress admin bar. There are many other ways you can customize it, depending on your needs.


Post a comment

Comments

Nothing yet..be the first to share wisdom.