You do not need to modify the woocommerce/templates/myaccount/navigation.php.
For customizing My account navigation menu
woocommerce_account_menu_items
filter hook to add new items to the menu.
array_slice()
to reorder them the way you want.
So using woocommerce_account_menu_items filter hook, it can be integrate perfectly your own items to woocommerce,
Possibility to redefine the endpoints of your own element through the WC Account Settings tab.
WC automatically changes the URL of the connection element when, for example, a change is made to the permalink settings / structure.
For example
// Note the low hook priority, this should give to your other plugins the time to add their own items...
add_filter( 'woocommerce_account_menu_items', 'add_my_menu_items', 99, 1 );
function add_my_menu_items( $items ) {
$my_items = array(
// endpoint => label
'2nd-item' => __( '2nd Item', 'my_plugin' ),
'3rd-item' => __( '3rd Item', 'my_plugin' ),
);
$my_items = array_slice( $items, 0, 1, true ) +
$my_items +
array_slice( $items, 1, count( $items ), true );
return $my_items;
}
I think you modified the WooCommerce template directly in core... woocommerce/templates/myaccount/navigation.php
you need to modify a WC template, the correct way to do it is to duplicate the template's path relative to the woocommerce/templates
folder into your theme/plugin's woocommerce
folder. For example in our case, you'd have to paste the template into:
child-theme/woocommerce/myaccount/navigation.php.