0

I use add_menu(), then I add number of add_submenu().

CODE

    add_menu_page( 'Config', 'MDW Config', 'manage_options', 'mdw-config', 'config_general_info', '', 45);
    add_submenu_page( 'mdw-config', 'General info', 'Info', 'manage_options', 'general-info', 'config_general_info');
    add_submenu_page( 'mdw-config', 'Google Analytics Integration', 'Google Analytics', 'manage_options', 'ga-integration', 'config_ga_integration');

And then some more submenus. What it achieves is:

enter image description here

As you can see, MDW Config, which is second argument of add_menu() duplicates, it seems like it's submenu of itself. I'm pretty sure it's possible to avoid it, as for example Appearance menu, which is default one, links directly to it's Themes submenu.

What am I doing wrong?

2 Answers 2

2

Try this:

    add_menu_page( 'MDW Config', 'MDW Config', 'manage_options', 'mdw-config', 'config_general_info', '', 45);
    add_submenu_page( 'mdw-config', 'General info', 'Info', 'manage_options', 'mdw-config', 'config_general_info');
    add_submenu_page( 'mdw-config', 'Google Analytics Integration', 'Google Analytics', 'manage_options', 'ga-integration', 'config_ga_integration');

What you have to do is simply overwrite the name of your first submenu page by assigning it to the same menu-slug but with different name.

1
  • Of course. I don't believe I didn't try it. Thanks.
    – wscourge
    Commented Nov 7, 2016 at 16:32
1

The only way I find it's to do it quickly, is with css

#toplevel_page_bb-plugins .wp-submenu .wp-first-item {
            display: none;
}

Of course, you will replace bb-plugins with your menu slug. And add this in the admin css file of your plugin.

3
  • Thanks, I already thought of that, but what I am looking for is more wordpress solution. I'm sure there is one, as they do it themselves. When I make sure they don't (...) I will do it your way :).
    – wscourge
    Commented Nov 7, 2016 at 16:29
  • I will try soon the @Sebastian solution, I didn't think enough about this...
    – Benoti
    Commented Nov 7, 2016 at 16:33
  • Yeah it works! But thank you anyway!
    – wscourge
    Commented Nov 7, 2016 at 16:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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