This thread is resolved. Here is a description of the problem and solution.
Problem:
The client is redesigning a website and wants the English menu to display in its entirety for all languages without manually creating the menu in each language. This is to avoid updating 10+ menus every time a page is added to the English menu.
Solution:
Currently, WPML does not support automatic duplication of menus across different languages. The client has two options:
1. Manually duplicate the menus by going to Appearance > Menus, clicking on the "+" sign to add menus in secondary languages, and inserting the English links and labels.
2. Implement a custom code solution. The client can try editing the provided code to fit their context or consult with professional contractors for assistance. The code provided earlier should be added to the functions.php file, ensuring a backup is made first due to potential risks:
$locations_to_omit = ['header']; //Append menu locations here. e.g. ['primary', 'footer']<br />add_filter('wp_nav_menu_args', function ($args) use ($locations_to_omit) {<br /> if (isset($args['theme_location']) && in_array($args['theme_location'], $locations_to_omit)) {<br /> $current_lang = apply_filters( 'wpml_current_language', null );<br /> do_action('wpml_switch_language', apply_filters( 'wpml_default_language', null ));<br /> <br /> add_filter('wp_nav_menu', function ($nav_menu) use ($current_lang){<br /> do_action('wpml_switch_language', $current_lang);<br /> return $nav_menu;<br /> }, 99);<br /> }<br /> <br /> return $args;<br />}, 1);
If these solutions do not resolve the issue or if the solution becomes outdated, we 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 5 replies, has 2 voices.
Last updated by 4 weeks ago.
Assisted by: Lucas Vidal de Andrade.