Created
October 20, 2012 15:30
-
-
Save WebEndevSnippets/3923584 to your computer and use it in GitHub Desktop.
WordPress: Add Login In Navigation (w Profile)
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
// Add Login Link in Navigation | |
add_filter( 'wp_nav_menu_items', 'we_nav_login_right', 10, 2 ); | |
function we_nav_login_right($menu, $args) { | |
$args = (array)$args; | |
$login = wp_loginout( $_SERVER['REQUEST_URI'], false ); | |
$profile = '<a class="profile" href=' . get_edit_profile_url($userid) . '>Profile</a>'; | |
//if not primary, return | |
//change primary to secondary for secondary menu (though will need some CSS done) | |
if ( $args['theme_location'] != 'primary' ) | |
return $menu; | |
if ( !is_user_logged_in() ) { | |
$menu .= '<li class="right login">' . $login . '</li>'; | |
return $menu; | |
} | |
else { | |
$menu .= '<li class="right login">' . $login . ' | ' . $profile . '</li>'; | |
return $menu; | |
} | |
} |
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
/* Login | Profile in Nav | |
------------------------------------------------------------ */ | |
#nav li.login a { | |
background: url(images/user.png) no-repeat left center; | |
padding: 7px 2px 6px 20px; | |
} | |
#nav li.login a.profile { | |
background: none; | |
padding: 7px 7px 6px 2px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment