I added two menus

register_nav_menus (
        'primary_menu' => esc_html__('Primary Menu', 'sre'),
        'footer_menu' => esc_html__('Footer Menu', 'sre'),

But I'm unable to remove the two old ones, Primary menu and Secondary menu enter image description here

When I use this code, it hides Primary menu but when I remove the code, it reappears in the list.

add_action( 'after_setup_theme', 'remove_default_menu', 11 );
function remove_default_menu(){

2 Answers 2


Seems like you're using a parent theme or a plugin that registers those menu locations. If that's the case then you shouldn't remove your last function. You need to keep the remove_default_menu function in your functions file.

If you are not using a parent theme or some sort of plugin than that means you are registering those menu locations yourself. If that's the case then you should check your code and remove the lines where you register them.

  • I knew I wasn't registering those menus but I didn't realize that this theme is using a parent theme and sure enough those menus are registered in the parent theme. Thanks!
    – Junky
    Sep 1 at 14:16
  • You're welcome, glad I could help!
    – DeltaG
    Sep 1 at 14:23

When I use this code, it hides Primary menu but when I remove the code, it reappears in the list.

This is to be expected. Nav menu locations are not persistent. They're not stored in the database. This is how many things work in WordPress. Taxonomies, post types, post statuses, widgets etc.

So the locations will only appear if register_nav_menus() is called and they will only be removed if unregister_nav_menu() is called. If you remove the code that calls unregister_nav_menu() then they're not going to be removed.

If you want to remove them permanently then you'd need to remove the code that's registering them in the first place. If this is happening in a parent theme or plugin then that's not an option so you will need to stick to running unregister_nav_menu().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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