Title: WP_Admin_Bar::add_group
Published: April 25, 2014
Last modified: May 20, 2026

---

# WP_Admin_Bar::add_group( array $args )

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_admin_bar/add_group/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/classes/wp_admin_bar/add_group/?output_format=md#parameters)
 * [More Information](https://developer.wordpress.org/reference/classes/wp_admin_bar/add_group/?output_format=md#more-information)
 * [Source](https://developer.wordpress.org/reference/classes/wp_admin_bar/add_group/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_admin_bar/add_group/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_admin_bar/add_group/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/classes/wp_admin_bar/add_group/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_admin_bar/add_group/?output_format=md#wp--skip-link--target)

Adds a group to a toolbar menu node.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wp_admin_bar/add_group/?output_format=md#description)󠁿

Groups can be used to organize toolbar items into distinct sections of a toolbar
menu.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_admin_bar/add_group/?output_format=md#parameters)󠁿

 `$args`arrayrequired

Array of arguments for adding a group.

 * `id` string
 * ID of the item.
 * `parent` string
 * Optional. ID of the parent node. Default `'root'`.
 * `meta` array
 * Meta data for the group including the following keys: `'class'`, `'onclick'`,`'
   target'`, and `'title'`.

## 󠀁[More Information](https://developer.wordpress.org/reference/classes/wp_admin_bar/add_group/?output_format=md#more-information)󠁿

 * Toolbar items are also called “nodes”. Nodes can be parents for other nodes, 
   which creates dropdown menus. When adding a group you’re actually adding a group
   node. Group nodes are not visible in the Toolbar, but nodes added to it are.
 * This function is a method of the [WP_Admin_Bar](https://developer.wordpress.org/reference/classes/wp_admin_bar/)
   class and `$wp_admin_bar global` object, which may not exist except during the‘`
   admin_bar_menu`‘ or ‘`[wp_before_admin_bar_render](https://developer.wordpress.org/reference/hooks/wp_before_admin_bar_render/)`‘
   hooks.
 * The Toolbar replaces the Admin Bar since WordPress Version 3.3.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_admin_bar/add_group/?output_format=md#source)󠁿

    ```php
    final public function add_group( $args ) {
    	$args['group'] = true;

    	$this->add_node( $args );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-admin-bar.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/class-wp-admin-bar.php#L271)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/class-wp-admin-bar.php#L271-L275)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_admin_bar/add_group/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_Admin_Bar::add_node()](https://developer.wordpress.org/reference/classes/wp_admin_bar/add_node/)`wp-includes/class-wp-admin-bar.php` |

Adds a node to the menu.

  |

| Used by | Description | 
| [wp_admin_bar_my_account_menu()](https://developer.wordpress.org/reference/functions/wp_admin_bar_my_account_menu/)`wp-includes/admin-bar.php` |

Adds the “My Account” submenu items.

  | 
| [wp_admin_bar_my_sites_menu()](https://developer.wordpress.org/reference/functions/wp_admin_bar_my_sites_menu/)`wp-includes/admin-bar.php` |

Adds the “My Sites/[Site Name]” menu and all submenus.

  | 
| [wp_admin_bar_appearance_menu()](https://developer.wordpress.org/reference/functions/wp_admin_bar_appearance_menu/)`wp-includes/admin-bar.php` |

Adds appearance submenu items to the “Site Name” menu.

  | 
| [wp_admin_bar_add_secondary_groups()](https://developer.wordpress.org/reference/functions/wp_admin_bar_add_secondary_groups/)`wp-includes/admin-bar.php` |

Adds secondary menus.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_admin_bar/add_group/?output_format=md#changelog)󠁿

| Version | Description | 
| [3.3.0](https://developer.wordpress.org/reference/since/3.3.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/classes/wp_admin_bar/add_group/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 2 content](https://developer.wordpress.org/reference/classes/wp_admin_bar/add_group/?output_format=md#comment-content-1480)
 2.    [Codex](https://profiles.wordpress.org/codex/)  [  10 years ago  ](https://developer.wordpress.org/reference/classes/wp_admin_bar/add_group/#comment-1480)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_admin_bar%2Fadd_group%2F%23comment-1480)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_admin_bar%2Fadd_group%2F%23comment-1480)
 4.  **Adding a group to a parent node**
 5.  This example adds a parent node, child nodes and a group to the toolbar.
 6.      ```php
         add_action( 'admin_bar_menu', 'add_nodes_and_groups_to_toolbar', 999 );
     
         function add_nodes_and_groups_to_toolbar( $wp_admin_bar ) {
     
         	// add a parent item
         	$args = array(
         		'id'    => 'parent_node',
         		'title' => 'parent node'
         	);
         	$wp_admin_bar->add_node( $args );
     
         	// add a child item to our parent item
         	$args = array(
         		'id'     => 'child_node',
         		'title'  => 'child node',
         		'parent' => 'parent_node'
         	);
         	$wp_admin_bar->add_node( $args );
     
         	// add a group node with a class "first-toolbar-group"
         	$args = array(
         		'id'     => 'first_group',
         		'parent' => 'parent_node',
         		'meta'   => array( 'class' => 'first-toolbar-group' )
         	);
         	$wp_admin_bar->add_group( $args );
     
         	// add an item to our group item
         	$args = array(
         		'id'     => 'first_grouped_node',
         		'title'  => 'first group node',
         		'parent' => 'first_group'
         	);
         	$wp_admin_bar->add_node( $args );
     
         	// add another child item to our parent item (not to our first group)
         	$args = array(
         		'id'     => 'another_child_node',
         		'title'  => 'another child node',
         		'parent' => 'parent_node'
         	);
         	$wp_admin_bar->add_node( $args );
     
         }
         ```
     
 7.  The output from this example in the toolbar will be:
 8.      ```php
          * parent node
          ** child node
          ** another child node
          ** first group node
         ```
     
 9.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_admin_bar%2Fadd_group%2F%3Freplytocom%3D1480%23feedback-editor-1480)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_admin_bar%2Fadd_group%2F)
before being able to contribute a note or feedback.