Thursday, 14 March 2013

Renaming Admin menu

Renaming the admin menu/submenu items is simple by using admin_head filter. Not only that, we can also change the Link of the menu/submenu items.

Consider the sample code to renaming the Labels. Just paste the following code in either plugin files or in the functions.php ( theme file ).

if(!function_exists('custom_admin_menu_labelrename')){

    function custom_admin_menu_labelrename(){

        global $submenu, $menu;

        /* we can get index of the menu by using this code print_r($menu);/print_r($submenu)*/

        $menu[2][0] = 'Overview'; /*Here I just changed the Dashboard label to Overview*/        

        $submenu['index.php'][0][2] = 'http://examplesite.com';/* Custom link to Home (submenu of Dashboard Menu) menu*/

        $submenu['index.php'][0][0] = 'My Home'; /*Home (submenu of Dashboard Menu)label to My Home*/       
       
    }
}

add_filter( 'admin_head', 'custom_admin_menu_labelrename' );

No comments:

Post a Comment