Created
August 31, 2012 13:02
-
-
Save ChromeOrange/3552413 to your computer and use it in GitHub Desktop.
Add login menu item to menus with 'My Account'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add login link to my account menu. | |
* | |
* Add this to your theme functions file | |
*/ | |
add_filter( 'wp_nav_menu_items', 'woocommerce_nav_menu_items_login', 10, 2 ); | |
function woocommerce_nav_menu_items_login( $items, $args ) { | |
if ( get_option('woocommerce_menu_logout_link')=='yes' && strstr($items, get_permalink(woocommerce_get_page_id('myaccount'))) && !is_user_logged_in() ) | |
$items .= '<li class="login"><a href="'. get_permalink(woocommerce_get_page_id('myaccount')) .'">'.__('Login', 'woocommerce').'</a></li>'; | |
return $items; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is great, using it now.