WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to get the menu location in the wp_update_nav_menu (during menu save action)

  add_action('wp_update_nav_menu', function ($id, $data = NULL)
        error_log( var_export($data, true) );

    }, 10, 2);

However, the data only contains the menu-name, so how can I get the menu location?

share|improve this question

get_nav_menu_locations will give you menu IDs keyed by location which should correspond to the $id also passed with wp_update_nav_menu.

add_action('wp_update_nav_menu', function ($id, $data = NULL){

    foreach( get_nav_menu_locations() as $location => $menu_id ){
        if( $id == $menu_id ){
            echo 'location is ' . $location;

}, 10, 2);
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.