-
AuthorPosts
-
February 26, 2022 at 1:12 pm #1342362
Hi team,
Hope you are doing fine. I had put the following code in functions.php of child theme. Now the issue is that the button is part of the menu and shows on mobile devices only, How do I put this code in correct manner so it will not display as twice on mobile devices. for your reference i am attaching the images for further clarification of issue.
Enfold theme issue of Login and logout button on Mobile Devices
// Add Log in / log out links to top menu add_filter( 'wp_nav_menu_items', 'add_loginout_link', 10, 2 ); function add_loginout_link( $items, $args ) { if (is_user_logged_in() && $args->theme_location == 'avia') { $items .= '<li><a href="https://brbbrothers.com/my-account/customer-logout/">Log Out</a></li>'; } elseif (!is_user_logged_in() && $args->theme_location == 'avia') { $items .= '<li><a href="https://brbbrothers.com/my-account/">Log In</a></li>'; } return $items; }-
This topic was modified 3 years, 8 months ago by
Yigit.
February 26, 2022 at 9:36 pm #1342421Hey tauqer30,
Thank you for the screenshot, I was able to find your site and found that your custom menu item li doesn’t include the classmenu-item
please include this class and it won’t show on mobile. Your code snippet above didn’t post correctly so I can’t advise on how to adjust it, if you need further help please include an admin login in the Private Content area.Best regards,
MikeFebruary 27, 2022 at 2:24 pm #1342464Sure,
It’s very helpful. The credentials are included in private content area.
February 27, 2022 at 2:37 pm #1342466Hi,
Thank you for the login, I adjusted your links to have the classmenu-itemso they only show on desktop
This is the new code:add_filter( 'wp_nav_menu_items', 'add_loginout_link', 10, 2 ); function add_loginout_link( $items, $args ) { if (is_user_logged_in() && $args->theme_location == 'avia') { $items .= '<li class="menu-item"><a href="https://your-site.com/my-account/customer-logout/">Log Out</a></li>'; } elseif (!is_user_logged_in() && $args->theme_location == 'avia') { $items .= '<li class="menu-item"><a href="https://your-site.com/my-account/">Log In</a></li>'; } return $items; }please check.
Best regards,
MikeMarch 1, 2022 at 12:43 pm #1342705Hi Team,
Thanks for the updated code. The code is working perfectly.
Many Thanks.
March 1, 2022 at 1:12 pm #1342707Hi,
Glad we were able to help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.Best regards,
Mike -
This topic was modified 3 years, 8 months ago by
-
AuthorPosts
- The topic ‘Add Login / Log out links to top menu’’ is closed to new replies.
