wp_add_nav_menu_item
Fires immediately after a new navigation menu item has been added.
Description
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.
- // run the action
- do_action( 'wp_add_nav_menu_item', $menu_id, $menu_item_db_id, $args );
- The following example is for adding a hook callback.
- // define the wp_add_nav_menu_item callback
- function action_wp_add_nav_menu_item( $menu_id, $menu_item_db_id, $args ) {
- // make action magic happen here...
- };
- // add the action
- add_action( 'wp_add_nav_menu_item', 'action_wp_add_nav_menu_item', 10, 3 );
- To remove a hook callback, use the example below.
- // remove the action
- 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
- do_action( 'wp_add_nav_menu_item', $menu_id, $menu_item_db_id, $args );