Hello am working on wordpress plugin and facing an issue while adding links in admin menu, am making a submenue
but it show duplicate entry.
Top level menu repeats in submenu I dont know why
please help
screen shots attached.
“In situations where a plugin is creating its own top-level menu, the
first submenu will normally have the same link title as the top-level
menu and hence the link will be duplicated. The duplicate link title
can be avoided by calling the add_submenu_page function the first time
with the parent_slug and menu_slug parameters being given the same
value.”
The Duplicate Sub-menu Item can be removed using the remove_submenu_page function:
By default the first submenu item is meant to be a clone of the main menu item, you can however change it.
From: codex.wordpress.org/Adding_Administration_Menus
The Duplicate Sub-menu Item can be removed using the remove_submenu_page function:
Use:
remove_submenu_page( string $menu_slug, string $submenu_slug );
Note that the sub-menu slug is the same as the top level menu slug.
Solution mentioned above didn’t work without adding a priority of “1” to my
This finally solved the issue with duplicated menu item.