Code Uncategorized WordPress

How to remove a nav menu location in WordPress 3.0.0

This function is in WordPress 3.0.1. You can now just call unregister_nav_menu and don’t need to put it in your child theme

One of the great additions to WordPress 3.0 is navigation menus.  One of the aspects that it contains is the ability for a theme to register a nav menu location and for the user to assign any menu they want to that location.  GREAT!  Except that a missing piece of functionality is the ability for Child Themes to remove a location that it might no longer want.  I’ve created a ticket and submitted a patch, but if you need that functionality now, just add the code below to you child theme’s functions.php file:
if (! function_exists(‘unregister_nav_menu’) ):
function unregister_nav_menu( $location ) {
global $_wp_registered_nav_menus;

if (is_array($_wp_registered_nav_menus) && array_key_exists( $location, $_wp_registered_nav_menus ) ){
unset( $_wp_registered_nav_menus[$location] );
return true;

return false;


Then all you need to do is call:
//Remove Twenty Ten Default Menu Location
At some point after the nav menu is registered. I like to use the init hook.

9 replies on “How to remove a nav menu location in WordPress 3.0.0”

I actually found this blog post while trying to learn how to do the opposite. I want to add more menu locations to my Twenty Ten theme. I’m assuming then that I have to register the location within functions.php and select the menu from the menu settings.

That’s exactly correct. I strongly encourage you to make your changes in a child theme then directly to the Twenty Ten files. That way you can still update Twenty Ten when future version containing new features and bug fixes are released.

Two things…

@aaron re: James’ idea… Is it strictly necessary to register new menu positions? It seems I can add as many menus as I like, and then simply use a widget to place that custom menu in the sidebar or footer.

Also, I’m having a bit of trouble unregistering *all* the twentyten sidebars in my child theme. In the comments of functions.php I find the following: “To override twentyten_widgets_init() in a child theme, remove the action hook and add your own function tied to the init hook.”

So in my child theme I added the line
remove_action( ‘widgets_init’, ‘twentyten_widgets_init’ );
but this has no discernible effect.

I can add a new function with extra sidebars, tied to the widgets_init hook and they are fine, but I’m not able to remove/overwrite the default stylings (before and after widget and title parameters) with my new function.


Used the tips in this post and those in the one regarding removal of the twentyten default header images to do two things:

// Remove twentyten Default Menu Location
add_action( ‘after_setup_theme’, ‘remove_default_twentyten_menu_loc’, 11 );
function remove_default_twentyten_menu_loc(){


// First, Remove default twentyten sidebars.
add_action( ‘after_setup_theme’, ‘remove_default_twentyten_sidebars’, 11 );
function remove_default_twentyten_sidebars(){
remove_action( ‘widgets_init’, ‘twentyten_widgets_init’ );

These might not be the best or preferred methods, but both served to clear allow me to override the default functions and build ones more specific to a child-theme. Thanks again for this.

@piedmont or whoever has deeper insight:

This could be very useful for child themes in general, could you please explain this code a bit more, especially the parts specific to Twenty Ten, e.g.:
– which of them are theme-specific?
– what to look for in child themes in order to replace them with the right values.

I must admit that as good as the concept of child themes works, getting rid of unnecessary stuff in functions.php keeps me scratching my head.

Here’s my take on things.

I think the default themes WP has put out are excellent, but they do lack an easy ‘undo’ button. That would be something! A ‘keep the layout but remove all functions’ button, or simply a css-only version of the default theme, to let people put together their own functions.php (because the way in which stylesheets are overridden is much simpler than overriding functions…and because simply copying and renaming twenetyten’s files to create your own child theme won’t undo the functions that come prepackaged with twentyten).

As I understand it, you can name a function anything you want. In that sense, everything is theme-specific. The fact that the functions included in the twentyten theme are named twentyten_something_blahblah is only important if the function needs to be unregistered/overridden.

If you’ve any experience with HTML, PHP or CSS (and no disrespect if you don’t, but it’s really helpful) just looking at the code included in twentyten’s functions.php and style.css will reveal many values.

The numbing zen thing to keep in mind (and it can be maddening) is that everything needs to work together. Ah, bitter dregs.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.