Created
March 18, 2016 10:48
-
-
Save larsmqller/e8e4b10e5e2a8abddc59 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 log out functionality in menu, add stuff to menu | |
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 == 'top_nav') { | |
$items .= '<li><a href="'. wp_logout_url() .'">Log Out</a></li>'; | |
} | |
elseif (!is_user_logged_in() && $args->theme_location == 'top_nav') { | |
$items .= '<li><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