ordPress管理控制台中更改WooCommerce产品菜单标

ordPress管理控制台中更改WooCommerce产品菜单标

本文介绍了在WordPress管理控制台中更改WooCommerce产品菜单标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们试图在后端标题菜单上更改产品页面,但是我们无法使用屏幕截图中的以下代码段:

We have tried to change the products page at the back end title menu but we couldn't using the snippet below in the screenshot:

我们需要将菜单标题"产品"都更改为"新标题"&将Sumbmenu 所有产品"更改为" All Submenu "

We need to change both the menu title "Products" to " New Title " & Sumbmenu "All Products" to " All Submenu "

add_filter( 'gettext', 'custom_translate_woocommerce_strings', 999, 3 );

function custom_translate_woocommerce_strings( $translated, $text, $domain ) {

    $translated = str_ireplace( 'Product', 'New Title', $translated );

    return $translated;
}

推荐答案

代码的第一部分调试,这将向您显示菜单详细信息.(您可以在以后将其删除)

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 adds the changes

// 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
function custom_change_admin_label() {
    global $menu, $submenu;

    $menu[26][0] = 'New Title';
    $submenu['edit.php?post_type=product'][5][0] = 'All Submenu';
}
add_action( 'admin_menu', 'custom_change_admin_label' );

这篇关于在WordPress管理控制台中更改WooCommerce产品菜单标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-10 22:48