Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #992358

    martinezg
    Participant

    I have 2 questions about the same issue. I want a button on the right hand side of the menu bar in the header that displays Log In or Log Out (whenever user already logged in)

    http://crowdlacuna.com/

    – How can I make the ‘LogIn’ button appear on the right hand side of the menu bar at the top rather than with the other icons?
    – How can I change the LogIn button to ‘LogOut’ whenever the user is already logged in?

    #992414

    Thai
    Moderator

    Hi There,

    Please add the following code under functions.php file locates in your child theme:

    add_filter( 'wp_nav_menu_items', 'autov_add_loginout_navitem', 10, 2 );
    function autov_add_loginout_navitem( $items, $args ) {
    	if( $args->theme_location == 'primary' ){
    		$login_item = '<li class="login">'.wp_loginout($_SERVER['REQUEST_URI'], false).'</li>';
    		$items .= $login_item;
    	}
    	return $items;
    }

    Hope it helps 🙂

    #996582

    martinezg
    Participant

    Hi, thanks for the code. How do I make that appear on the right hand side of the header? See screenshot what it displays right now

    #996759

    Paul R
    Moderator

    Hi,

    You can add this under Custom > Edit Global CSS in the Customizer.

    
    .x-navbar .desktop .x-nav {
         width: calc(100% - 60px);
    }
    
    .x-navbar .desktop .x-nav>li.menu-item-520 {
           float:right;
    }
    

    Hope that helps.

    #998692

    martinezg
    Participant

    hi paul, that didnt do anything

    #998871

    Rupok
    Member

    Hi there,

    I have tested the code and it must work if you add this correctly. I can’t see the code on your site. So either you didn’t add this correctly or your previous code have glitch that’s preventing this to generate correctly. So check the other codes and fix them as well.

    Cheers!

    #1000701

    martinezg
    Participant

    thanks. i’ve fixed it by placing it at the top rather than the button of the CSS.

    #1000827

    Prasant Rai
    Moderator

    You are most welcome. 🙂