my problem is the following: I have a website which has three languages (EN, DE, FR). I am using the xili languages plugin to make the website multilingual. With the default Sparkling theme (which is BTW an absolutely cool website!) I can only add maximum 2 menus. Since I do have 3 languages I need to do 3 menus as they differ completely in the menu names. For example the “Welcome” page is: EN=Welcome, DE=Willkommen, FR=Bonjour.
I also read and applied this answer to add 3 menus (named: primary, secondary, third) like written in this topic.
The problem I however have is that I have now 3 menus which do show up on the website. So I thought I wanted to add to the function sparkling_header_menu() (located in the extras.php) an if-query to see which language is active. However either I do not get it or I do a mistake but after adding the if query the whole website went blank. Sorry guys, I forgot what I wrote there but it was something like:
if (ID='menu_FR'):
//show French menu
endif;
Does anyone know how to make it, so that there are basically 3 menus for 3 languages but that only one of these menus (the correct one according to the currently selected language) is shown.
Thanks for your help!
Ok, now I played a bit with it but I have still a big problem. But first of all my code which is situated in the extras.php
if ( ! function_exists( 'sparkling_header_menu' ) ) :
/**
* Header menu (should you choose to use one)
*/
function sparkling_header_menu() {
// display the WordPress Custom Menu if available
// Get the selected language to show the menu
$selected_language_for_menu=the_curlang();
echo $selected_language_for_menu; //show result to make it visible what is selected
if ($selected_language_for_menu="fr_fr")
{wp_nav_menu(array(
'menu' => 'primary',
'theme_location' => 'primary',
'depth' => 2,
'container' => 'div',
'container_class' => 'collapse navbar-collapse navbar-ex1-collapse',
'menu_class' => 'nav navbar-nav',
'fallback_cb' => 'wp_bootstrap_navwalker::fallback',
'walker' => new wp_bootstrap_navwalker()));
} elseif ($selected_language_for_menu="de_de")
{wp_nav_menu(array(
'menu' => 'secondary',
'theme_location' => 'secondary',
'depth' => 2,
'container' => 'div',
'container_class' => 'collapse navbar-collapse navbar-ex1-collapse',
'menu_class' => 'nav navbar-nav',
'fallback_cb' => 'wp_bootstrap_navwalker::fallback',
'walker' => new wp_bootstrap_navwalker()));
} else {
wp_nav_menu(array(
'menu' => 'third',
'theme_location' => 'third',
'depth' => 2,
'container' => 'div',
'container_class' => 'collapse navbar-collapse navbar-ex1-collapse',
'menu_class' => 'nav navbar-nav',
'fallback_cb' => 'wp_bootstrap_navwalker::fallback',
'walker' => new wp_bootstrap_navwalker()
));
}
} /* end header menu */
endif;
What is now my problem now which I cannot solve:
The first if-query is always right (no matter which language is currently active), so I only get the primary menu shown up. Anybody has a clue where my problem/mistake is?