add_menu_page creates an extra submenu item

When creating a new main menu item with add_menu_page in the wordpress admin interface, this automatically generates a first submenu item that has the same name as the main menu. Which looks like this: 

To avoid this, it’s necessary to set the same slug for the main navigation and the first (!) submenu item: 

	'Ophi Mainmenu',
	10 );

	'Ophi Submenu1',
	array($this, 'submenuOneAction')

	'Ophi Submenu2',
	array($this, 'submenuTwoAction')

Via the duplicate slag ophi-mainmenu the unwanted submenu is replaced by submenu1 and now looks like this: 

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.