Some WordPress plugins have many options. It is not readable to put all options and data in one single page. So we assign a main menu in WordPress. Then we allot several sub menus below the main menu. When doing this, a major problem is the main menu item is again repeated as the first item of sub menu. For better understanding please refer the screenshot below.
Sub Menu Before
Here, gAnalytics is repeated both in main menu and as first item in sub menu. Our aim is to change the “gAnalytics” sub menu item to “Dashboard”. Here is the code doing our trick.
if ( isset( $submenu[‘ga_dashboard’] ) )
$submenu[‘ga_dashboard’] = ‘Dashboard’;
ga_dashboard is the slug of main menu. Here is how the menu appears after adding the code.
Sub Menu After
You can add this code inside the function where you add the main menu and sub menu pages. That is, write the above code after add_menu_page() function.