add_action for saving a custom menu

Say you have custom menus enabled with your WP theme. Is there any action associated with saving a menu once you’ve arranged it accordingly? To further clarify: say you’ve arranged a menu with some links and some posts, how might you get the titles of the posts in said menu upon saving (clicking the “Save Menu” button)?

2 Answers
2

At least in 3.4.1, there is an action for that: wp_update_nav_menu

See here.

Then you can get the items in your menu with something like:

add_action('wp_update_nav_menu', 'my_get_menu_items');
function my_get_menu_items($nav_menu_selected_id) {
    $items = wp_get_nav_menu_items($nav_menu_selected_id);
}

Leave a Comment