1

I'm using the code at https://markwilkinson.me/2014/11/altering-wordpress-admin-menus/ to change plugin-created top-level admin-menu items to submenu items of a 'misc' top-level item.

It works fine on those items which don't have their own submenu, but on items which have their own submenu the submenu disappears.

I don't know if the code can be appropriately modified, or if it can how to do it.

Mo'men Mohamed
  • 1,851
  • 20
  • 24
gulliver
  • 127
  • 6
  • 1
    Add your code to check it – Mo'men Mohamed Aug 21 '17 at 07:32
  • check page HTML source, may be the html is there but your theme style is preventing it. – Alice Aug 21 '17 at 09:06
  • @Mo'men Mohamed ... thanks. No code to add - using what's on that page, and simply swapping the slug of an item with a submenu for one without. – gulliver Aug 21 '17 at 10:16
  • @ Alice... Thanks. It's not the css. – gulliver Aug 21 '17 at 10:17
  • You cannot add a 3rd level of menus in WP admin. See the answer to [How to Add a Third Level Sub Menu to the Wordpress Admin Menu](https://wordpress.stackexchange.com/questions/226990/how-to-add-a-third-level-sub-menu-to-the-wordpress-admin-menu) from wordpress.stackexchange.com – FluffyKitten Aug 21 '17 at 14:32
  • @ FluffyKitten... thanks. Ah, that explains it. So, those two-level space-hogging plugin-added menu items get to stay where they are... and if I ever need an additional level for stuff I create I'll use tab. – gulliver Aug 21 '17 at 15:41
  • I'm going to add that as an answer just for completeness in case anyone else is asking the same question - even though it isn't your desired outcome, it looks like 'its not possible' is the answer ! – FluffyKitten Aug 22 '17 at 17:07

1 Answers1

1

Wordpress does not allow you to add a 3rd level of menus in WP admin.

See the answer to How to Add a Third Level Sub Menu to the Wordpress Admin Menu from wordpress.stackexchange.com

The answer from Karthikeyani explains why it currently isn't possible:

The definition of add_submenu_page requires the parent slug name. For example:

add_menu_page ( 'Test Menu', 'Test Menu', 'read', 'testmainmenu', '', '' );
add_submenu_page ( 'testmainmenu', 'Test Menu', 'Child1', 'read', 'child1', '');

The first parameter of the add_submenu_page is parent slug name $parent_slug. You may think you could use child1 ($menu_slug) as parent slug name to create the third level, but this does not work.

The parameters definition and source section in the Wordpress developer documentation for add_submenu_page clearly states that you can only use the name of the main menu of the plugin or the file name of the WordPress plugin in parent slug name.

add_submenu_page Ref: https://developer.wordpress.org/reference/functions/add_submenu_page/

FluffyKitten
  • 13,824
  • 10
  • 39
  • 52