Force a registered menu based on language selection
-
How can I force a registered menu based on if a user switches between languages?
if(function_exists('register_nav_menu')): register_nav_menu( 'english_nav_menu', esc_html__('English Navigation Menu', 'theme_name')); register_nav_menu( 'dutch_nav_menu', esc_html__('Dutch Navigation Menu', 'theme_name')); register_nav_menu( 'burger_menu', esc_html__('English Burger Navigation Menu', 'theme_name')); register_nav_menu( 'dutch_burger_menu', esc_html__('Dutch Burger Navigation Menu', 'theme_name')); endif;When I am using the MslsMenu Add-on, it switches the language of the page, but the menu stays the same as the original language.
-
Do you have these menus in all of your sites defined? In most case you just edit the labels of one menu in every site. You can of course define content by languages (also without the MSLS):
if ( function_exists( 'register_nav_menu' ) ) : $locale = get_locale(); switch ( $locale ) : case 'nl_NL' : register_nav_menu( 'a_nav_menu', esc_html__( 'A Nav Menu', 'theme_name')); break; default : register_nav_menu( 'b_nav_menu', esc_html__( 'B Nav Menu', 'theme_name' ) ); endswitch; endif;Hi Dennis,
Your solution doesn’t seem to work for me (or it is not working well with my theme). Is there another way to force a particular menu item once you use MSLS to swap pages?
Thanks in advance for your support!
Here is an example of what issue I’m referring to:
http://briddgecvm.cluster005.ovh.net/faq/
When I translate the page, the top menu stays static.
I would like to assign the Dutch page a new menu.When you go to the translated page:
http://briddgecvm.cluster005.ovh.net/nl/dit-is-een-faq/
it has a new menu, but only when you directly open it, not being referred by the previous English page. Is there something I can add in my php that will force call the Dutch menu?Solved.
What was the solution? 🙂
The topic ‘Force a registered menu based on language selection’ is closed to new replies.