Remove Duplicate Sub Menu in WordPress

By default, when adding a new top level menu to your plugin or theme administration pages, WordPress adds a menu item with the same name. However, you might want that menu item to be name differently. For example, I like to name the first item ‘Settings’ or ‘Global Settings’.With the following code fragment you will be able to do just that.

So how are we able to do that? It’s quite easy actually. You should register all your plugin’s or theme’s menu and sub menus inside the ‘admin_menu’ hook. WordPress add theses menus into a global variable called menu and ‘submenu’ subsequently. We are interested in the sub menu variable.

The structure of that variable is very simple as well. It is an array with the keys being the slug of the parent. The value is an array of submenu’s (array of various settings with the first one being the title.

To change the first submenu’s name (the duplicate submenu).

If you want to remove it, you can do it as well, just unset it.