Skip to content

Instantly share code, notes, and snippets.

@nutsandbolts
Created March 28, 2015 06:08
Show Gist options
  • Save nutsandbolts/d83df7786de40f745050 to your computer and use it in GitHub Desktop.
Save nutsandbolts/d83df7786de40f745050 to your computer and use it in GitHub Desktop.
Add login/logout link to Genesis nav
//* Add login or logout to menu
add_filter( 'wp_nav_menu_items', 'sp_add_loginout_link', 10, 2 );
function sp_add_loginout_link( $items, $args ) {
// Change 'primary' to 'secondary' to put the login link in your secondary nav bar
if ( $args->theme_location != 'primary' )
return $items;
if ( is_user_logged_in() ) {
$items .= '<li class="menu-item right"><a href="'. wp_logout_url() .'">Log Out</a></li>';
} else {
$items .= '<li class="menu-item right"><a href="'. site_url('wp-login.php') .'">Log In</a></li>';
}
return $items;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment