我想在“Dashboard”之上移动“Langgan”菜单标签(用于订阅键)并加粗“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”Bold,您需要添加位于活动主题中的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;
}