<?php //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->menu != 'main-menu' ) return $items; $redirect = ( is_home() ) ? false : get_permalink(); if( is_user_logged_in( ) ) $link = '' . __( 'Logout' ) . ''; else $link = '' . __( 'Login' ) . ''; return $items.= '
Add a login/logout link to a WordPress navigation menu
1. Add the following code to your theme's functions.php file and change the menu area name if you are not using "primary". For WordPress 3.0 and up.
'. $link . ' ';
}add_filter( 'wp_nav_menu_items', 'add_login_out_item_to_menu', 10, 2 );
/** END **/
?>
Labels:
wordpress
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment