Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

sdsd

sdsd

// Add Toolbar Menus
function custom_toolbar() {
	global $wp_admin_bar;

	$args = array(
		'id'     => 'parent-menu',
		'title'  => __( 'Main Menu', 'text_domain' ),
	);
	$wp_admin_bar->add_menu( $args );

	$args = array(
		'id'     => 'child-menu',
		'parent' => 'parent-menu',
		'title'  => __( 'Sub Menu', 'text_domain' ),
	);
	$wp_admin_bar->add_menu( $args );

}

// Hook into the 'wp_before_admin_bar_render' action
add_action( 'wp_before_admin_bar_render', 'custom_toolbar', 999 );