1

I want to move the "Langgan" menu label (for subscriptions key) on top of "Dashboard" and bold the "Langgan".

Currently I'm using the code below for "Langgan" part inside my theme function.php file:

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;
}

enter image description here

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
TheNewbie
  • 35
  • 1
  • 4

1 Answers1

0

To set a custom label for 'subscriptions' key and reorder menu items to get it at the beginning, try this instead (this will replace your function):

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;
}

This code goes in function.php file of your active child theme (or theme) or also in any plugin file.

Tested and works


To make "Langgan" Bold you should need to add in your styles.css file located in your active theme, the following CSS rule:

li.woocommerce-MyAccount-navigation-link--subscriptions {
    font-weight: bold !important;
}

OR

nav.woocommerce-MyAccount-navigation > ul > li:first-child {
    font-weight: bold !important;
}
LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
  • Hi @LoicTheAztec The sorting work great. However, the navigation still shown Subscriptions instead of Langgan. I have replaced the previous code with the new one given above. Any other step I'm missing? – TheNewbie Dec 19 '17 at 16:51
  • @TheNewbie **Update** -The problem was in your hooked function (the hook priority and the number of arguments are wrong). I have changed `, 0, 15 );` to `, 100, 1 );` … now it works just fine, try it please… – LoicTheAztec Dec 19 '17 at 19:54
  • It work great! Thank you for the help. Appreciate it! – TheNewbie Dec 20 '17 at 02:17