wp_add_nav_menu_item
Action HookDescription
Fires immediately after a new navigation menu item has been added.Hook Information
File Location |
wp-includes/nav-menu.php
View on GitHub
|
Hook Type | Action |
Line Number | 565 |
Hook Parameters
Type | Name | Description |
---|---|---|
int
|
$menu_id
|
ID of the updated menu. |
int
|
$menu_item_db_id
|
ID of the new menu item. |
array
|
$args
|
An array of arguments used to update/add the menu item. |
Usage Examples
Basic Usage
<?php
// Hook into wp_add_nav_menu_item
add_action('wp_add_nav_menu_item', 'my_custom_function', 10, 3);
function my_custom_function($menu_id, $menu_item_db_id, $args) {
// Your custom code here
}
Source Code Context
wp-includes/nav-menu.php:565
- How this hook is used in WordPress core
<?php
560 *
561 * @param int $menu_id ID of the updated menu.
562 * @param int $menu_item_db_id ID of the new menu item.
563 * @param array $args An array of arguments used to update/add the menu item.
564 */
565 do_action( 'wp_add_nav_menu_item', $menu_id, $menu_item_db_id, $args );
566 }
567
568 /*
569 * Associate the menu item with the menu term.
570 * Only set the menu term if it isn't set to avoid unnecessary wp_get_object_terms().
PHP Documentation
<?php
/**
* Fires immediately after a new navigation menu item has been added.
*
* @since 4.4.0
*
* @see wp_update_nav_menu_item()
*
* @param int $menu_id ID of the updated menu.
* @param int $menu_item_db_id ID of the new menu item.
* @param array $args An array of arguments used to update/add the menu item.
*/
Quick Info
- Hook Type: Action
- Parameters: 3
- File: wp-includes/nav-menu.php
Related Hooks
Related hooks will be displayed here in future updates.