简体   繁体   中英

How to rename a menu tab under WooCommerce tab on WordPress admin dashboard

I need help in renaming a tab menu item under woocommerce tab on wordpress admin. We installed a plugin that appears as a submenu on woocommerce tab. Can anyone please help me on this?

I found this code below to rename a tab menu, but I dont know what is the tabmenu key of it. Or anyone here how to check tab menu key on my current tab menu items?

add_action( 'admin_menu', 'custom_change_admin_label', 99);
function custom_change_admin_label() {
    global $menu;
    //global $submenu;
    $menu[5][0] = 'Articles';
}

Thank you

The first part of the code is to debug , this will show you the menu in detail on the dashboard. (you can remove this afterwards)

The 2nd part in this example changes the 'coupons' label to 'voucher'

It is therefore a matter of adjusting based on the detail

// DEBUG: This displays the complete wordpress admin menu on your dashboard for admin only.
function debug_admin_menus() {
    global $menu, $submenu, $pagenow;
    if ( current_user_can('manage_options') ) {
        if( $pagenow == 'index.php' ) {  // print on dashboard
            echo '<pre>', print_r( $menu, 1 ), '</pre>'; // top level menus
            echo '<pre>', print_r( $submenu, 1 ), '</pre>'; // submenus
        }
    }
}
add_action( 'admin_notices', 'debug_admin_menus' );

// Change label, in this example changes the 'coupons' label to 'voucher'
function custom_change_admin_label() {
    global $menu, $submenu;

    $submenu['woocommerce'][2][0] = 'Voucher'; // rename 'coupons' label
}
add_action( 'admin_menu', 'custom_change_admin_label' );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM