Change WooCommerce products menu title in WordPress admin dashboard(在 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:
我们需要将菜单标题产品"更改为新标题"&总结菜单所有产品"到所有子菜单"
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)
这个例子的第二部分添加了变化
因此需要根据细节进行调整
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
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 产品菜单标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 WordPress 管理仪表板中更改 WooCommerce 产品菜单


- 带有通配符的 Laravel 验证器 2021-01-01
- 正确分离 PHP 中的逻辑/样式 2021-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- 没有作曲家的 PSR4 自动加载 2022-01-01
- Laravel 仓库 2022-01-01
- Mod使用GET变量将子域重写为PHP 2021-01-01
- 如何定位 php.ini 文件 (xampp) 2022-01-01
- PHP Count 布尔数组中真值的数量 2021-01-01
- SoapClient 设置自定义 HTTP Header 2021-01-01
- 从 PHP 中的输入表单获取日期 2022-01-01