How make menus work together
-
Hi there,
I am building a website (based on WP) for a company that has two locations (A and B).
The menu of the website is relative simple, but some of the pages should be different based on the location)
– Home (Home A and Home B)
– About
– Competences
– Accountants (A and B)
– Contact (A and B)There is a landing page where the end user “chooses a location”. Internally the end user is redirected to Home A (for location A) or Home B (location B).
Currently I have configured my nav-menu like this:
– Home (empty link, not clickable)
– Home A
– Home B
– About
– Competences
– Accountants (empty link, not clickable)
– Accountants A
– Accountants B
– Contact (empty link, not clickable)
– Contact A
– Contact BEverything works perfect, but the end user loses the sense that he has chosen a location. Because every time they need to choose the desired location from the dropdowns.
Is there a way to have the nav-menu to be “context sensitive”. This means that I do not have submenus, but when I click from Contact A on Home, I actually go to Home A (and not Home B).
Thanks in advance
-
I am sorry for the stupid title of the post.
I was trying to better explain my intention and I was divided between:
– “How to make menus work together” – thinking about using the locations as a menu (A and B) and making the main nav-menu sensitive to the locations menu
– AND “Can I make a menu context sensitive” – thinking about saving the location as a parameter (or even a custom field) and changing the nav-menu to be case sensitive.Finally, I wrote something totally incoherent as the page title.
Hi,
I don’t think it’s possible.
It will be much easier if you have a landing page and two WordPress sub domains, sub domain A and sub domain B
Use the same design throughout and user will have a seamless experience.
Thank you
Denzel proposes a good idea, but FWIW, contextual menus are possible 🙂
It can be tricky though. First you need to keep track of which location the user has selected. How this is done depends on what UX you want. Once selected is that always the choice, or should it be selected for each session? Can the user jump back to the other location at any time?
There are also choices for how to modify the menu by context. I’m assuming your theme is using wp_nav_menu() to output menus. You can call wp_nav_menu with a different menu parameter depending on location. A complete menu would be needed for each location.
wp_nav_menu() has a number of filters that give you the option of replacing certain parts of a menu with other content. The full HTML output is filtered with “wp_nav_menu”. “wp_nav_menu_objects” filter passes to your callback all the menu items in an array, which makes accessing particular items easier.
Utilizing a custom WP_Walker object gives you the opportunity to alter menu items as they are being built, instead of replacing something that has already been built. This is probably the best option, but properly creating a proper walker object can be pretty confusing unless you have some good walker coding experience.
Those are the high points of dynamically altering menus, but there are even more filters available to do so. Review the source code for wp_nav_menu to see the other filters.
The topic ‘How make menus work together’ is closed to new replies.