//Add login/logout link to naviagation menu
function add_login_out_item_to_menu( $items, $args ){

//change theme location with your them location name
if( is_admin() || $args->theme_location != 'primary' )
return $items;

$redirect = ( is_home() ) ? false : get_permalink();
if( is_user_logged_in( ) )
$link = '<a href="' . wp_logout_url( $redirect ) . '" title="' . __( 'Logout' ) .'">' . __( 'Logout' ) . '</a>';
else $link = '<a href="' . wp_login_url( $redirect ) . '" title="' . __( 'Login' ) .'">' . __( 'Login' ) . '</a>';

return $items.= '<li id="log-in-out-link" class="menu-item menu-type-link">'. $link . '</li>';
}
//add_filter( 'wp_nav_menu_items', 'add_login_out_item_to_menu', 50, 2 );

apply_filters ( 'wp_nav_menu_items', 'add_login_out_item_to_menu', array('menu' => 'menu-name') );

Use this function in theme to display the menu:

wp_nav_menu();
Advertisements