Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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-menu') {
- $items .= '<li><a href="'. wp_logout_url() .'">Log Out</a></li>';
- }
- elseif (!is_user_logged_in() && $args->theme_location == 'top-menu') {
- $items .= '<li><a href="'. site_url('wp-login.php') .'">Log In</a></li>';
- }
- return $items;
- }
Add Comment
Please, Sign In to add comment