Vertical custom menu showing sub-menu on click?

From a WPUniversity reader:

Hi wp university love your site,

I’m having another problem with one of my menus. This time its a vertical custom menu, I would like to know how to acomplish with a jquery script(i enqued it and it is registered through functions.php) to hide/show sub-menu items when parent item is clicked? Also i would need to target only specific parents, some will have their child collapsed all time.

Here is the menu i created:

here you can see wich childs should be open and wich closed: – sidebar OTVORENA GALERIJA. Im going to style the new menu like the list you can see there.

Any jquery suggestions?

Thanks for your answers.

Hi there, you’ll probably want to hide your .sub-menu class (which is a standard WordPress submenu class) in your css. Then with jQuery click functionality open that sub menu on click. To find out how to do onclick events with jQuery please head on to as they have many examples of how to use jQuery specifically.

You can also find answers on stack exchange such as ( ) to find specific jQuery answers.

On this site we’re aiming at answering questions specific to WordPress.


About the author

Guest Contributor

Guest Contributor

WPUniversity Contributors help us make WordPress more approachable for non-developers. Want to get involved? Get all the details here.