本文介紹了在 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 產品菜單標題的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!