RSS

How To Change WordPress Admin Sub Menu Text

05 Sep

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

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.

1
2
3
global $submenu;
if ( isset( $submenu[‘ga_dashboard’] ) )
    $submenu[‘ga_dashboard’][0][0] = ‘Dashboard’;

ga_dashboard is the slug of main menu. Here is how the menu appears after adding the code.

Sub Menu After

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.

Advertisements
 
Leave a comment

Posted by on September 5, 2013 in Wordpress

 

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: