WPML Plugin Not displaying multilingual Menus
-
16-10-2019 - |
Question
I'm using WordPress 3.0 Menus, which the WPML (wordpress multilingual) plugin claims to have added support for in a recent release. I am using the most current version of the plugin.
My problem is that using the following to call my nav menus
<?php wp_nav_menu( array( 'theme_location' => 'primary', 'container_class' => 'menu-header', 'menu_id' => 'menu-primary-navigation' ) ); ?>
is pulling up only the English translation of the menu.
Here is an image of the WPML admin panel and how the menus are setup multilingual:
[link to image] http://cl.ly/42RW [link to image] http://cl.ly/42o0
You can see the site currently in development:
http://anasmadance.com.s66112.gridserver.com/
The problem is that when you go to the French translated page, the menu is still in English (despite the fact that I've already set up the French menu)
Solution
I ended up having to manually detect the language, here's how I solved it:
<?php if (ICL_LANGUAGE_CODE == 'fr')
{
// display the menu en francais
wp_nav_menu( array( 'menu' => 'Navigation principale', 'theme_location' => 'primary', 'container_class' => 'menu-header', 'menu_id' => 'menu-primary-navigation' ) );
}
else {
// show them the menu in English
wp_nav_menu( array( 'menu' => 'Primary Navigation', 'theme_location' => 'primary', 'container_class' => 'menu-header', 'menu_id' => 'menu-primary-navigation' ) );
}; ?>