editing menu for dropdown as apposed to link

In a menu I want to know how to have a parent item (I don't mean parent in terms of URL, just menu) when clicked on, instead of linking to page, can expand the submenu it has under it. I can't post my URL, but this really is not theme or plugin specific anyway. I just want to know how a menu item can be used to open a submenu when clicked on, as opposed to linking to a page. Thanks so much for all your help and good luck with the new hosting thing!

  • Nastia
    • Support Rock Star

    Hello Jonathan , I trust you are doing well today!

    Please let me know, do you are looking for a custom code for a theme, so a menu will open on a click or this is a question regarding WordPress setting?

    If it a question regarding WordPress settings, to set the menu as a child, please go to Appearance > Menus, select the menu you wish to edit.

    Drag and drop the child menu right bellow the parent menu. Please see the screencast bellow:
    https://monosnap.com/file/rUtYWcwvxoxBTPYRfMEYpN3cHDqMjf

    We also have this very good, quick tutorial, about how to create menus, submenus and more.
    https://premium.wpmudev.org/project/introduction-to-menus/

    If this is a question regarding how to create a clickable menu, please see the following tutorial:
    http://www.w3schools.com/howto/howto_js_dropdown.asp

    Let me know if you have any further questions!

    Cheers,
    Nastia

  • Jonathan
    • The Crimson Coder

    Usually you guys at wpmudev are great, but sadly, here you did not even take the time to read what I have wrote. I very clearly told you that I have a menu with a parent page and child pages. When a user click on the parent, normally that goes to the parent page. I want instead that is should open the submenu, i.e. the list of the child pages. Is there something unclear about my question?

    One of the links you sent me has an example that is what I am trying to do. Look at http://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_js_dropdown
    How can I have my wordpress menu item do that?

  • Nastia
    • Support Rock Star

    Hello Jonathan , I hope you are doing well today!

    Please accept my sincere apologies for the inconvenience. Usually, the submenu opens on a hover, if your theme doesn't have this option from the beginning, this will require custom coding.

    We do not suggest hardcoding inside a theme, so it would be best to create a child theme first. To create a child theme please follow this manual.

    To make a menu open on click, it will need jQuery toggle, you can see an example here.

    The jQuery code needs to be added in the header.php file of your theme. Of course, you will need to change CSS classes inside the jQuery code so it matches with the CSS of your theme.

    Let me know if you have any further questions!

    Cheers,
    Nastia

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.