Posts Tagged ‘WordPress Navigation Menus’

 
 

How To Add a login/logout link to Your Navigation Menu

Posted 25 Jan 2011 — by WPGPL Team
Category WordPress Tricks

New WordPress 3 Menus is Awesome feature, I really like it, using WordPress Navigation Menu, we can create more sophisticated menu ever seen. We can arrange our menu more easily and many more. Now we will share How To Add a login/logout link to your navigation menu.

You need to write this code on your functions.php and the login/logout link will be automatically added on your WordPress Menu Navigation

add_filter('wp_nav_menu_items', 'add_login_logout_link', 10, 2);
function add_login_logout_link($items, $args) {

		ob_start();
		wp_loginout('index.php');
		$loginoutlink = ob_get_contents();
		ob_end_clean();

		$items .= '<li>'. $loginoutlink .'</li>';

	return $items;
}

Read the rest of this entry »