Rename “Login” to “My Account” for logged in users

Create a menu link to Main Menu named Login linking to WooCommerce “Account details”, and with the code below, when a user will login, it will be changed to My Account.

// Rename "Login" to "My Account" (for logged in users) Link @ WooCommerce/WP Nav Menu  */
 
add_filter( 'wp_nav_menu_items', 'dynamic_label_change', 10, 2 ); 
 
function dynamic_label_change( $items, $args ) { 
   if ( ! is_user_logged_in() ) { 
      $items = str_replace( "My account", "Login", $items ); 
   } 
   return $items; 
} 
Scroll to Top