• Resolved locomoco

    (@locomoco)


    So I am using a plugin “Userpro” and in order to have the popup function, I have to add the following link:

    <a href=#" class="popup-login">Login via popup</a>

    So basically I would like to have a link in my navigation menu that says “Login” and when I click on it, it should open a popup with the login page.

    I’ve been trying to figure how this can be done and digging through the different files and documentations for many days now but to no avail. I would really appreciate if someone could point me in the right direction!

Viewing 15 replies - 1 through 15 (of 24 total)
  • Hii , you can use jquery to add a menu item in the wp_nav_menu.

    
            $( document ).ready(function() {
                $(".main-menu ul").append("<a href='#' class='popup-login'>Login via popup</a>");
            });

    (Pleasechange the menu(.main-menu ul) reference class according to your Site)

    Or you can use wordpress wp_nav_menu_items hook.

    function add_last_nav_item($items) {
      return $items .= "<a href='#' class='popup-login'>Login via popup</a>";
    }
    add_filter('wp_nav_menu_items','add_last_nav_item');
    • This reply was modified 7 years, 5 months ago by sumithsuku11.
    Thread Starter locomoco

    (@locomoco)

    Edit: I added it into my theme’s function.php and it works! Thanks!

    However, I’ve realised that the text style is different from the others (screenshots attached). How do I style the text?

    View post on imgur.com

    • This reply was modified 7 years, 5 months ago by locomoco.
    • This reply was modified 7 years, 5 months ago by locomoco.
    • This reply was modified 7 years, 5 months ago by locomoco.

    May be have missed the li tag. Please change the code accordingly. Or you have specific class for the a tag please apply the same class to the a tag.

    function add_last_nav_item($items) {
      return $items .= "<li><a href='#' class='popup-login'>Login via popup</a></li>";
    }
    add_filter('wp_nav_menu_items','add_last_nav_item');

    Regards
    Sumith

    • This reply was modified 7 years, 5 months ago by sumithsuku11.
    • This reply was modified 7 years, 5 months ago by sumithsuku11.
    Thread Starter locomoco

    (@locomoco)

    You are a lifesaver!

    One more question, is it possible to make this be shown only to users who are not logged in?

    ??

    Ok please try the modified code . And let me know if you need more help on the same 1

    function add_last_nav_item($items) {
    	if ( ! is_user_logged_in() ) {   
    	  return $items .= "<li><a href='#' class='popup-login'>Login via popup</a></li>";
    	} else{
    	return $items;
    	}
    }
    add_filter('wp_nav_menu_items','add_last_nav_item');

    Regards
    Sumith

    Thread Starter locomoco

    (@locomoco)

    It works perfect, thank you so much! 1 problem down, a few hundred more to go!^^

    We can kill all of the problems ??

    Best of Luck ??

    • This reply was modified 7 years, 5 months ago by sumithsuku11.
    Thread Starter locomoco

    (@locomoco)

    Would you be able to point me in the direction of where I might be able to read up on making those dropdown menu list upon mouse hover? I am trying to have a link that shows the user’s profile name and when clicked, it brings them to their account page and when mouse hovered, it will show a menu with “edit profile” and “logout”

    Thanks again!

    Ok .It seems to be you need more control over account menus . So it would be better split the wp_nav_menu and the account menus separate in header HTML. Will you able to do that ? Also need some coding to work like that.

    Thread Starter locomoco

    (@locomoco)

    Yikes, that sounds complicated.. Does that mean I need 2 header.php or something? Sorry, my understanding of the inner workings of wordpress is severely limited :O

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    @locomoco, Please don’t contact people outside of the forums even if they provide contact deatils.

    @sumithsuku11, It’s okay to say you cannot provide that level of support. It’s also okay to say you don’t know the answer. Please do not ask people to contact you off the forums.
    https://make.www.ads-software.com/support/handbook/forum-welcome/#the-bad-stuff

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Would you be able to point me in the direction of where I might be able to read up on making those dropdown menu list upon mouse hover? I am trying to have a link that shows the user’s profile name and when clicked, it brings them to their account page and when mouse hovered, it will show a menu with “edit profile” and “logout”

    @locomoco, Could you get the menu displaying on the page? We can easily show you how to dropdowns appear on-hover, but first you need to get the menu there.

    Thread Starter locomoco

    (@locomoco)

    Hi, yes I think I got the menu with the dropdown list on hover, which I added via Appearance -> Menu. It looks like this (screenshot attached) at the moment (with the list of links upon hover of “My profile”. But instead of “My profile”, I’m hoping to have it show the logged-in user’s first and last name instead.

    Sorry about breaking the forum rules!

    View post on imgur.com

    • This reply was modified 7 years, 5 months ago by locomoco.
    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Unfortunately we’re not going to be able to provide a solution unless we can see the website

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    But instead of “My profile”, I’m hoping to have it show the logged-in user’s first and last name instead.

    Wait, that’s not a dropdown problem.

Viewing 15 replies - 1 through 15 (of 24 total)
  • The topic ‘How do I add new links to menu’ is closed to new replies.