Skip to content

Instantly share code, notes, and snippets.

@DanielSantoro
Created March 11, 2016 21:16
Show Gist options
  • Save DanielSantoro/ca105d917d5e526bec3a to your computer and use it in GitHub Desktop.
Save DanielSantoro/ca105d917d5e526bec3a to your computer and use it in GitHub Desktop.
Modified Functions Area
/*-----------------------------------------------------------------------------------*/
/* You can add custom functions below */
/*-----------------------------------------------------------------------------------*/
// Add Login & Logout to Navigation Menu. Found on http://www.pootlepress.com
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-menu') {
$items .= '<li><a href="'. wp_logout_url() .'">Log Out</a></li>';
}
elseif (!is_user_logged_in() && $args->theme_location == 'primary-menu') {
$items .= '<li><a href="'. site_url('wp-login.php') .'">Log In</a></li>';
}
return $items;
/*-----------------------------------------------------------------------------------*/
/* Don't add any code below here or the sky will fall down */
/*-----------------------------------------------------------------------------------*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment