Title: unregister_nav_menu
Published: April 25, 2014
Last modified: February 24, 2026

---

# unregister_nav_menu( string $location ): bool

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/unregister_nav_menu/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/unregister_nav_menu/?output_format=md#return)
 * [More Information](https://developer.wordpress.org/reference/functions/unregister_nav_menu/?output_format=md#more-information)
 * [Source](https://developer.wordpress.org/reference/functions/unregister_nav_menu/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/unregister_nav_menu/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/unregister_nav_menu/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/unregister_nav_menu/?output_format=md#user-contributed-notes)

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

Unregisters a navigation menu location for a theme.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/unregister_nav_menu/?output_format=md#parameters)󠁿

 `$location`stringrequired

The menu location identifier.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/unregister_nav_menu/?output_format=md#return)󠁿

 bool True on success, false on failure.

## 󠀁[More Information](https://developer.wordpress.org/reference/functions/unregister_nav_menu/?output_format=md#more-information)󠁿

##### 󠀁[Usage:](https://developer.wordpress.org/reference/functions/unregister_nav_menu/?output_format=md#usage)󠁿

    ```php
    unregister_nav_menu( 'primary' );
    ```

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

    ```php
    function unregister_nav_menu( $location ) {
    	global $_wp_registered_nav_menus;

    	if ( is_array( $_wp_registered_nav_menus ) && isset( $_wp_registered_nav_menus[ $location ] ) ) {
    		unset( $_wp_registered_nav_menus[ $location ] );
    		if ( empty( $_wp_registered_nav_menus ) ) {
    			_remove_theme_support( 'menus' );
    		}
    		return true;
    	}
    	return false;
    }
    ```

[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#L115)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/nav-menu.php#L115-L126)

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

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

Do not use. Removes theme support internally without knowledge of those not used by themes directly.

  |

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

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

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/unregister_nav_menu/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 3 content](https://developer.wordpress.org/reference/functions/unregister_nav_menu/?output_format=md#comment-content-6007)
 2.    [studiolxv](https://profiles.wordpress.org/studiolxv/)  [  4 years ago  ](https://developer.wordpress.org/reference/functions/unregister_nav_menu/#comment-6007)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Funregister_nav_menu%2F%23comment-6007)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Funregister_nav_menu%2F%23comment-6007)
 4.  **Delete a previously registered location**
 5.  Calling [get_nav_menu_locations()](https://developer.wordpress.org/reference/functions/get_nav_menu_locations/)
     will show you an array of all the nav location slugs and their associated menu
     ID you have registered/ and or used in the past. The [get_nav_menu_locations()](https://developer.wordpress.org/reference/functions/get_nav_menu_locations/)
     function checks a theme mod so to fully unregister/remove menu location we need
     an extra step missing from **[unregister_nav_menu()](https://developer.wordpress.org/reference/functions/unregister_nav_menu/)**
     by removing the location slug from the **get_theme_mod(‘nav_menu_locations’)**
     array and then resetting the theme mod without the $location we want to remove.
 6.      ```php
         /**
          * Delete a previously registered location
          * 
          * @param $location The slug used to register the menu in the first place
          */
         if (!function_exists('delete_nav_menu_location')) {
         	function delete_nav_menu_location($location)
         	{
     
         		$locations = get_theme_mod('nav_menu_locations');
     
         		if (is_array($locations) && array_key_exists($location, $locations)) {
         			unset($locations[$location]);
         			set_theme_mod('nav_menu_locations', $locations);
         			return true;
         		}
         		return false;
         	}
         }
         ```
     
 7.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Funregister_nav_menu%2F%3Freplytocom%3D6007%23feedback-editor-6007)
 8.   [Skip to note 4 content](https://developer.wordpress.org/reference/functions/unregister_nav_menu/?output_format=md#comment-content-1349)
 9.    [Codex](https://profiles.wordpress.org/codex/)  [  10 years ago  ](https://developer.wordpress.org/reference/functions/unregister_nav_menu/#comment-1349)
 10. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Funregister_nav_menu%2F%23comment-1349)
     Vote results for this note: -2[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Funregister_nav_menu%2F%23comment-1349)
 11. **Basic Example**
 12.     ```php
         <?php unregister_nav_menu( 'primary' ); ?> 
         ```
     
 13.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Funregister_nav_menu%2F%3Freplytocom%3D1349%23feedback-editor-1349)

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