do_action( 'admin_menu', string $context )

Fires before the administration menu loads in the admin.

Parameters Parameters


(string) Empty context.

Top ↑

More Information More Information

  • This action is used to add extra submenus and menu options to the admin panel’s menu structure. It runs after the basic admin panel menu structure is in place.
  • This action mustn’t be placed in an admin_init action function because the admin_init action is called after admin_menu.

Top ↑

Source Source

File: wp-admin/includes/menu.php

View on Trac

Top ↑

Changelog Changelog

Version Description
1.5.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 1 content
    Contributed by Aurovrata Venet

    If you want to change a menu label, you can hook this action and change the global $menu, $submenu values,

    add_action( 'admin_menu', 'change_media_label' );
    function change_media_label(){
      global $menu, $submenu;
      $menu[10][0] = 'Photos/Videos';
      $submenu['upload.php'][5][0] = 'All Photos/Videos';
      $submenu['upload.php'][10][0] = 'Upload new';
  2. Skip to note 2 content
    Contributed by stevenlinx

    Example migrated from Codex:

    The example comes from the wpautop-control plugin, in which the code is used to add an options page to the “Settings” menu.

    add_action('admin_menu', 'wpautop_control_menu');
    function wpautop_control_menu() {
      add_submenu_page('options-general.php', 'wpautop-control', 'wpautop control', 'manage_options', 'wpautop-control-menu', 'wpautop_control_options');
  3. Skip to note 3 content
    Contributed by Milad

    This snippet add admin menu and submenu HTML content

    	//call the 'add_menu_page' function with 'admin_menu' action hook
    	add_action( 'admin_menu', array( $this, 'wpdocs_add_menu_page' ), 99 );
         * Add page to admin menu
        public function wpdocs_add_menu_page() {
                esc_html__( 'WooCommerce B2B Sales Agents', 'woocommerce-b2b-sales-agents' ),
                esc_html__( 'WooCommerce B2B Sales Agents', 'woocommerce-b2b-sales-agents'),
                esc_html__( 'Commissions', 'woocommerce-b2b-sales-agents' ),
                esc_html__( 'Commissions', 'woocommerce-b2b-sales-agents' ),
                array( $this, 'wpdocs_add_menu_page_callback' )
         * Add page to admin menu callback
        public function wpdocs_add_menu_page_callback() {
            include WCB2BSA_ABSPATH . 'includes/views/html-admin--page-commissions.php';

You must log in before being able to contribute a note or feedback.