在 Woocommerce 我的帐户部分重新排序菜单项
Reorder menu items in Woocommerce My Account section
我想将 "Langgan" 菜单标签 (用于订阅密钥) 移动到 "Dashboard" 之上,并加粗 "Langgan"。
目前我在主题 function.php
文件中的 "Langgan" 部分使用下面的代码:
add_filter( 'woocommerce_account_menu_items', 'rename_my_account_menu_items', 0, 15 );
function rename_my_account_menu_items( $items ) {
// HERE set your new label name for subscriptions
$items['subscriptions'] = __( 'Custom label', 'woocommerce' );
return $items;
}
要为 'subscriptions'
键设置自定义标签并重新排序菜单项以在开头获取它,请试试这个 (这将取代您的功能):
add_filter( 'woocommerce_account_menu_items', 'rename_my_account_menu_items', 100, 1 );
function rename_my_account_menu_items( $items ) {
$ordered_items = array();
// HERE set your custom label name for 'subscriptions' key in this array
$subscription_item = array( 'subscriptions' => __( 'Langgan', 'woocommerce' ) );
// Remove 'subscriptions' key / label pair from original $items array
unset( $items['subscriptions'] );
// merging arrays
$items = array_merge( $subscription_item, $items );
return $items;
}
此代码位于您的活动子主题(或主题)的 function.php 文件或任何插件文件中。
已测试并有效
要使 "Langgan" 变为粗体,您需要在位于活动主题中的 styles.css 文件中添加以下 CSS 规则:
li.woocommerce-MyAccount-navigation-link--subscriptions {
font-weight: bold !important;
}
或
nav.woocommerce-MyAccount-navigation > ul > li:first-child {
font-weight: bold !important;
}
我想将 "Langgan" 菜单标签 (用于订阅密钥) 移动到 "Dashboard" 之上,并加粗 "Langgan"。
目前我在主题 function.php
文件中的 "Langgan" 部分使用下面的代码:
add_filter( 'woocommerce_account_menu_items', 'rename_my_account_menu_items', 0, 15 );
function rename_my_account_menu_items( $items ) {
// HERE set your new label name for subscriptions
$items['subscriptions'] = __( 'Custom label', 'woocommerce' );
return $items;
}
要为 'subscriptions'
键设置自定义标签并重新排序菜单项以在开头获取它,请试试这个 (这将取代您的功能):
add_filter( 'woocommerce_account_menu_items', 'rename_my_account_menu_items', 100, 1 );
function rename_my_account_menu_items( $items ) {
$ordered_items = array();
// HERE set your custom label name for 'subscriptions' key in this array
$subscription_item = array( 'subscriptions' => __( 'Langgan', 'woocommerce' ) );
// Remove 'subscriptions' key / label pair from original $items array
unset( $items['subscriptions'] );
// merging arrays
$items = array_merge( $subscription_item, $items );
return $items;
}
此代码位于您的活动子主题(或主题)的 function.php 文件或任何插件文件中。
已测试并有效
要使 "Langgan" 变为粗体,您需要在位于活动主题中的 styles.css 文件中添加以下 CSS 规则:
li.woocommerce-MyAccount-navigation-link--subscriptions {
font-weight: bold !important;
}
或
nav.woocommerce-MyAccount-navigation > ul > li:first-child {
font-weight: bold !important;
}