Make sub menu items a main link in the admin menu using fuctions.php

OK, it’s a bit messy, but it works. Take a look

function remove_submenus() {
  global $submenu;
  unset($submenu['themes.php'][10]); // Removes Menu  
}
add_action('admin_menu', 'remove_submenus');



function new_nav_menu () {
    global $menu;
    $menu[99] = array('', 'read', 'separator', '', 'menu-top menu-nav');
    add_menu_page(__('Nav Menus', 'mav-menus'), __('Nav Menus', 'nav-menus'), 'edit_themes', 'nav-menus.php', '', 99);
}
add_action('admin_menu', 'new_nav_menu');

Essentially it is removing the nav menu settings from the Appearance sub-panel, then re-adding it as a top level page (similar to a plugin). You can set an icon URL in there as well. The only part I can’t get working the way I want is the positioning.

Leave a Comment