wp_add_nav_menu_item

Fires immediately after a new navigation menu item has been added.

Description

do_action( 'wp_add_nav_menu_item', (int) $menu_id, (int) $menu_item_db_id, (array) $args ); 

Parameters (3)

0. $menu_id (int)
ID of the updated menu.
1. $menu_item_db_id (int)
ID of the new menu item.
2. $args (array)
An array of arguments used to update/add the menu item.

Usage

To run the hook, copy the example below.
  1. // run the action 
  2. do_action( 'wp_add_nav_menu_item', $menu_id, $menu_item_db_id, $args ); 
The following example is for adding a hook callback.
  1. // define the wp_add_nav_menu_item callback 
  2. function action_wp_add_nav_menu_item( $menu_id, $menu_item_db_id, $args ) { 
  3. // make action magic happen here... 
  4. }; 
  5.  
  6. // add the action 
  7. add_action( 'wp_add_nav_menu_item', 'action_wp_add_nav_menu_item', 10, 3 ); 
To remove a hook callback, use the example below.
  1. // remove the action 
  2. remove_action( 'wp_add_nav_menu_item', 'action_wp_add_nav_menu_item', 10, 3 ); 

Defined (1)

The action is defined in the following location(s).

/wp-includes/nav-menu.php  
  1. do_action( 'wp_add_nav_menu_item', $menu_id, $menu_item_db_id, $args );