Support » Themes and Templates » Log In and Log/Out link in Top Nav menu

  • Hello,

    How to add Log In/Log Out link in Top Nov menu. The that I have in the right navigation bar in the following link.

    In all my links I passed urls of different pages but here I can’t pass login page url because I want this text to change to “Log Out” when a user logins.


Viewing 1 replies (of 1 total)
  • Mods: Could you please change the thread title to Log In and Log/Out link in Top Nav menu so that it gets picked up on search results properly?

    autovall: To add a Login/Out link as a nav menu item, add the following code to your functions.php file:

    function autov_add_loginout_navitem($items) {
    	$login_item = '<li class="login">'.wp_loginout($_SERVER['REQUEST_URI'], false).'</li>';
        $items .= $login_item;
    	return $items;
    add_filter('wp_nav_menu_items', 'autov_add_loginout_navitem');

    That will add a login link to all your menus. If you wish to add the link to only one menu, change the last line to this:

    add_filter('wp_nav_menu_[slug]_items', 'autov_add_loginout_navitem');

    Make sure you replace [slug] with the targeted menu’s slug.
    That should do it.

Viewing 1 replies (of 1 total)
  • The topic ‘Log In and Log/Out link in Top Nav menu’ is closed to new replies.