Support » Fixing WordPress » Custom Menu Solution
5 years, 7 months ago
I’m working on a WordPress site with a custom menu. Here’s how it breaks down:
About Page (sub-menu)
Contact Page (sub-menu)
Info Page (sub-menu)
I’m setting up one main menu for navigation, but here’s the catch: within that menu, each page will have sub-menus – the sub-menus will only appear when you are on that page.
For example if you are on the About Page (or any of it’s sub pages) the sub-menu for About will appear – other sub-menus (such as Contact & Info pages) will by hidden.
These are not drop down menus, but rather sub menus that appear on each page.
Below is the html markup for the About us section of the menu for example:
<li>About Sub Link 1</li>
<li>About Sub Link 2</li>
<li>About Sub Link 3</li>
I’m looking for suggestions on how I can hide menus when you are not on that main page or it’s sub-pages. Obviously I know I can hid it with CSS, but I need to set this up dynamically with PHP.
Is there a way to give each sub-menu a custom class?
The default is ‘sub-menu’.
Currently it is: <ul class="sub-menu">
But I’d like to change it to: <ul class="about-sub-menu">