Home » Hooks » admin_bar_menu

The admin_bar_menu is a WordPress hook that allows developers to add new items to the admin bar that is visible in the WordPress admin area. This hook is used to extend the WordPress admin bar by adding custom menu items, sub-menus, and actions.

The admin bar is a sticky bar that appears at the top of the WordPress admin area, which contains links to helpful resources and actions. The admin_bar_menu hook provides a way for developers to add custom items to this menu easily.

To use this hook, developers can add their custom menu items and sub-menus using the add_menu() function. The function takes two arguments, the first being the ID of the item and the second being the label that should appear on the menu. Developers can also add custom actions using the add_action() function.

Here’s an example usage code for adding a custom link to the admin bar:

function my_custom_admin_bar_item( $wp_admin_bar ) {
    $args = array(
        'id'    => 'my-custom-item',
        'title' => 'My Custom Item',
        'href'  => ''
    $wp_admin_bar->add_node( $args );
add_action( 'admin_bar_menu', 'my_custom_admin_bar_item', 999 );

In this example, we are adding a new item to the admin bar with the ID "my-custom-item", the title "My Custom Item", and the URL "". The add_node() function is used to add the menu item to the admin bar using the $args array.

This is just a simple example, but the admin_bar_menu hook can be used to add much more complex menu items, sub-menus, and actions to the WordPress admin bar.

Learn More on

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