-
AuthorPosts
-
June 15, 2014 at 11:43 am #279073
Hey Guys!
First of all you guys have done an awesome job. Congrats! This theme is simply amazing.
I have a simple problem and would appreciate a quick repy on that.I want to place a “Login” button on the Navigation menu with an icon. It would be nice if the color of the button is yellow, same as in my logo. Please check the beta website for the color.
The icon simply would look like this in the given exapmle website with a yellow background.
The second thing I am looking for is that a function which replaces “Login” button with a “Logout” button when the user logged in.
How can I do that without using a plugin ?Or is it simply possible to assign a button with an icon to a menu item without using any codes ?
Thanks in advance
June 16, 2014 at 3:38 am #279198Hi geanguru!
Thank you for using the theme.
You can add something like this on functions.php:
add_filter( 'wp_nav_menu_items', 'avf_add_login_item', 10, 2 ); function avf_add_login_item ( $items, $args ) { $loginout = wp_loginout('', false); if ($args->theme_location == 'avia') { $items .= "<li class='login_link $sub2'>".$loginout."</li>"; } return $items; }
Use the .login_link css selector to modify the look of the loginout menu item.
Regards,
IsmaelJune 16, 2014 at 6:46 am #279262Hi Ismael,
Thank you for your quick response.
To be honest I decided to show a completely different menu when the user is logged in. So instead of replacing “Login” button with “Logout” button I want to replace whole menu with a second custom menu.
To do that I used below mentioned function
function my_wp_nav_menu_args( $args = '' ) { if( is_user_logged_in() ) { $args['menu'] = 'logged-in'; } else { $args['menu'] = 'logged-out'; } return $args; } add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );
Where “logged-in” and “logged-out” represents two different custom menus I have created.
But the problem with this function is that it changes the footer menu as well.
How can I modify the function to make it replace the menu only in header ?
Thank you very much in advance
June 16, 2014 at 10:38 am #279331Hi!
Thank you for the info.
Did you create two menus called logged-in and logged-out? If I am not mistaken, the code that you posted should call the logged-in menu when the user is logged in and the menu called logged-out when the user is not logged in. If you created those two menus, please try to use this:
function my_wp_nav_menu_args( $args = '' ) { if( is_user_logged_in() && $args['theme_location'] == 'avia' ) { $args['menu'] = 'logged-in'; } else { $args['menu'] = 'logged-out'; } return $args; } add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );
Best regards,
IsmaelJune 16, 2014 at 10:59 am #279343Hey Ismael,
Thanks a lot for your immediate response.
Yes I have already created two custom menus. As described above “logged-in” menu when the user logged in and “logged-out” menu when the user logged out.
The function you provided works fine but it still hasnt solved my problem yet.
The main problem with above mentioned code is that it changes the menu in footer area as well.Please see the regarding website here http://www.geanguru.com
I guess there should be some “else” command for the footer menu so called “secondary” or whatsoever. Dont you think ?
I couldnt solve the problem on my own so your help is highly appreciated.Thanks in advance
- This reply was modified 10 years, 5 months ago by geanguru.
June 19, 2014 at 5:27 am #280987 -
AuthorPosts
- You must be logged in to reply to this topic.