Rename or Remove My Account Menu Items
Tidies the My Account navigation by renaming items and hiding ones you do not use, such as Downloads on a store without digital products.
Opens WPIDE on
Code
add_filter( 'woocommerce_account_menu_items', function ( $items ) {
// Endpoint => new label.
$rename = array(
'orders' => 'My orders',
'edit-address' => 'Addresses',
);
// Endpoints to hide.
$remove = array( 'downloads' );
foreach ( $remove as $key ) {
unset( $items[ $key ] );
}
foreach ( $rename as $key => $label ) {
if ( isset( $items[ $key ] ) ) {
$items[ $key ] = $label;
}
}
return $items;
}, 20 );
Notes
Edit the $rename and $remove lists. Keys are the endpoint names (orders, downloads, edit-address, edit-account).
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.