Title: _wp_menus_changed
Published: November 20, 2017
Last modified: February 24, 2026

---

# _wp_menus_changed()

## In this article

 * [Source](https://developer.wordpress.org/reference/functions/_wp_menus_changed/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/_wp_menus_changed/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/_wp_menus_changed/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/_wp_menus_changed/?output_format=md#wp--skip-link--target)

This function’s access is marked private. This means it is not intended for use 
by plugin or theme developers, only by core. It is listed here for completeness.

Handles menu config after theme change.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/_wp_menus_changed/?output_format=md#source)󠁿

    ```php
    function _wp_menus_changed() {
    	$old_nav_menu_locations    = get_option( 'theme_switch_menu_locations', array() );
    	$new_nav_menu_locations    = get_nav_menu_locations();
    	$mapped_nav_menu_locations = wp_map_nav_menu_locations( $new_nav_menu_locations, $old_nav_menu_locations );

    	set_theme_mod( 'nav_menu_locations', $mapped_nav_menu_locations );
    	delete_option( 'theme_switch_menu_locations' );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/nav-menu.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/nav-menu.php#L1215)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/nav-menu.php#L1215-L1222)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/_wp_menus_changed/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_map_nav_menu_locations()](https://developer.wordpress.org/reference/functions/wp_map_nav_menu_locations/)`wp-includes/nav-menu.php` |

Maps nav menu locations according to assignments in previously active theme.

  | 
| [set_theme_mod()](https://developer.wordpress.org/reference/functions/set_theme_mod/)`wp-includes/theme.php` |

Updates theme modification value for the active theme.

  | 
| [delete_option()](https://developer.wordpress.org/reference/functions/delete_option/)`wp-includes/option.php` |

Removes an option by name. Prevents removal of protected WordPress options.

  | 
| [get_nav_menu_locations()](https://developer.wordpress.org/reference/functions/get_nav_menu_locations/)`wp-includes/nav-menu.php` |

Retrieves all registered navigation menu locations and the menus assigned to them.

  | 
| [get_option()](https://developer.wordpress.org/reference/functions/get_option/)`wp-includes/option.php` |

Retrieves an option value based on an option name.

  |

[Show 1 more](https://developer.wordpress.org/reference/functions/_wp_menus_changed/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/_wp_menus_changed/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/_wp_menus_changed/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.9.0](https://developer.wordpress.org/reference/since/4.9.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2F_wp_menus_changed%2F)
before being able to contribute a note or feedback.