Add WooCommerce MyAccount Page Login/Logout to Menu

This code adds a login/logout link to your WordPress primary menu to log the user into the WooCommerce My Account page and then also log out to the same or different page.

It differs from the referred article as that adds the WordPress default login/logout page.

The menus need to be registered via register_nav_menu and positioned with theme_location, so the trick is to find the registered menu name. You can find this in the dashboard on the menus page – then inspect with browser dev tools to see what it is.

Menu Location Dashboard

Dashboard Menus Page

 

Menu Location Menu Name

See Menu Name in Code

 

So in the above example, the name to use would be header

ref