如何替换我的帐户并在Woocommerce中添加登录/注销链接到菜单?

I am using woocommerce and I add the one menu My Account using woocommerce plugin But I want to show the menu login and logout instead of My Account which I add the into menu. I also added the script into functions.php result is same.

add_filter( 'wp_nav_menu_items', 'add_loginout_link', 10, 2 );

function add_loginout_link( $items, $args ) {

   if (is_user_logged_in() && $args->theme_location == 'primary_navigation') {

       //echo "hello friend how are";

       $items .= '<li><a href="'. wp_logout_url( get_permalink( woocommerce_get_page_id( 'myaccount' ) ) ) .'">Log Out</a></li>';

   }

   elseif (!is_user_logged_in() && $args->theme_location == 'primary_navigation') {

       $items .= '<li><a href="' . get_permalink( woocommerce_get_page_id( 'myaccount' ) ) . '">Log In</a></li>';

   }

   return $items;

}

When I am using jupitor theme and when I see the theme location of My Account Menu I get

Primary Navigation I have a one doubt is I have to add the My Account menu first then I add the login and logout menu.

Your above code will add login/logout links to menu. You do not have to add My Account menu.

Please check your theme_location. If theme location is correct then login/logout link will add to menu.

For check theme_location you have to search register_nav_menus in functions.php file of your theme. If you find it in functions.php file then you can see theme_location inside register_nav_menus code.