That's only possible with jQuery. Create the admin menus and submenus that you want, and add jQuery in admin_head
to run in all admin pages.
It's a matter of finding your admin menu anchors and changing its href
attribute. In this example, the admin menus are modified to point to nav-menus.php?action=edit&menu=MENU_ID
:
add_action( 'admin_menu', function() {
add_menu_page(
'My custom menu Settings',
'Menus',
'manage_options',
'my-menus',
function(){ echo 'This does not show up'; },
null,
25
);
add_submenu_page(
'my-menus' ,
'My custom submenu-1',
'Menu 1',
'manage_options',
'my-menus', // <---- Same as main menu, change to "sub-menu1" to see effect
function(){}
);
add_submenu_page(
'my-menus' ,
'My custom submenu-2',
'Menu 2',
'manage_options',
'sub-menu2',
function(){}
);
});
# See http://stackoverflow.com/questions/5673269/ for <<<HTML usage
add_action( 'admin_head', function (){
echo <<<HTML
<script type="text/javascript">
jQuery(document).ready( function($) {
topmenu = $('#toplevel_page_my-menus');
nav_menu1 = 'nav-menus.php?action=edit&menu=1';
nav_menu2 = 'nav-menus.php?action=edit&menu=2';
topmenu.find('a[href="admin.php?page=my-menus"]').attr('href',nav_menu1);
topmenu.find('a[href="admin.php?page=sub-menu2"]').attr('href',nav_menu2);
});
</script>
HTML;
});