Tagged: x
-
AuthorPosts
-
May 15, 2016 at 10:43 am #992358
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)
– 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?May 15, 2016 at 11:57 am #992414Hi 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 🙂
May 17, 2016 at 9:00 pm #996582Hi, 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
May 18, 2016 at 12:00 am #996759Hi,
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.
May 18, 2016 at 10:04 pm #998692hi paul, that didnt do anything
May 19, 2016 at 1:09 am #998871Hi 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!
May 19, 2016 at 9:10 pm #1000701thanks. i’ve fixed it by placing it at the top rather than the button of the CSS.
May 19, 2016 at 10:33 pm #1000827You are most welcome. 🙂
-
AuthorPosts