#29: wp_edit_nav_menu_walker

The wp_edit_nav_menu_walker filter allows you to change the Walker class used when adding menu items.

It was added in 3.4.

It is evaluated in wp_ajax_add_menu_item() in the wp-admin/includes/ajax-actions.php file.

wp_edit_nav_menu_walker accepts 2 arguments:

  1. string $class The Walker class to use when adding menu items. Default is ‘Walker_Nav_Menu_Edit’
  2. int $menu_id The menu id. Uses the value of $_POST['menu'].

Example:

The following example changes the Walker class used when adding new menu items. Note: This example does not include the custom Walker class, it’s just an example to demonstrate how to tell WordPress to use your class instead of Walker_Nav_Menu_Edit.

View the code example on Gist.

Have a suggested improvement? You can fork the Gist and comment back with the link. If all is agreeable, I’ll merge in your changes. Crowd-sourced documentation FTW!

Leave a Reply

Your email address will not be published. Required fields are marked *