This thread is resolved. Here is a description of the problem and solution.
Problem:
The client is trying to use one menu for all languages on their site using WPML, but the main documentation method is not working. They are only translating one page into 40 different languages and want the same main English navigation buttons for all languages.
Solution:
1. We suggested checking if all content linked by the menu is translated, as WPML should automatically handle menu translations once the linked content is translated. More details can be found here: Translating Menus Documentation.
2. If the automatic translation is not suitable, we provided a custom code snippet to force the use of the English menu across all languages. Add the following code to the site's functions.php file:
add_filter('wp_get_nav_menu_items', 'force_english_menu_for_all_languages', 10, 3);<br />function force_english_menu_for_all_languages($items, $menu, $args) {<br /> if (!is_admin() && $args->theme_location === 'primary') {<br /> $english_menu = wp_get_nav_menu_object('Main Menu');<br /> if ($english_menu && $english_menu->term_id !== $menu->term_id) {<br /> $items = wp_get_nav_menu_items($english_menu->term_id);<br /> }<br /> }<br /> return $items;<br />}
Replace 'Main Menu' with the actual menu name and ensure the theme location matches your theme’s menu location.
3. An alternative is to hardcode the menu in the header.php file, but this method lacks support for WordPress menu management features.
If this solution does not apply to your case, or if it seems outdated, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If further assistance is needed, please open a new support ticket at WPML Support Forum.
This is the technical support forum for WPML - the multilingual WordPress plugin.
Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.
This topic contains 3 replies, has 0 voices.
Last updated by 3 weeks, 6 days ago.
Assisted by: Bruno Kos.