0
votes

I can iterate through the top level Wordpress menu items to change the name but I now need to iterate through the sub menu items of that menu. I know I can do it using exact values $submenu['edit.php'][5][0] = 'New Label'; but it's for a plugin where the menu item may not be in the same position every time so that won't work.

I've got this code for the top level menus.

function _rename_top_level_menu( $original, $new ) {
        global $menu;

        foreach( $menu as $key => $value ) {
           if( $original === $value[0]) {
             $menu[$key][0] = $new;
           }
        }
 }
1

1 Answers

0
votes

Have you tried to use menu walker?

Although the Walker class has many uses, one of the most common usages by developers is outputting HTML for custom menus (usually ones that have been defined using the Appearance → Menus screen in the Administration Screens).