0
我使用woocommerce,並使用woocommerce插件添加一個菜單我的帳戶但我想顯示菜單登錄和註銷,而不是我添加到菜單中的我的帳戶。我也將腳本添加到functions.php結果是相同的。如何替換我的賬戶並添加登錄/註銷鏈接到Woocommerce的菜單?
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;
}
當我使用jupitor主題,當我看到我的帳戶菜單主題的位置,我得到
主導航 我有一個疑問,就是我得先加我的帳戶菜單然後我添加登錄和註銷菜單。
是的,我給了錯誤的主題位置我的主題位置是主菜單 –