Skip to content

Instantly share code, notes, and snippets.

@ChromeOrange
Created August 31, 2012 13:02
Show Gist options
  • Save ChromeOrange/3552413 to your computer and use it in GitHub Desktop.
Save ChromeOrange/3552413 to your computer and use it in GitHub Desktop.
Add login menu item to menus with 'My Account'
<?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;
}
?>
@spraveenitpro
Copy link

this is great, using it now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment