Skip to content Skip to sidebar

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 Bruno Kos 3 weeks, 6 days ago.

Assisted by: Bruno Kos.

Author Posts
July 7, 2025 at 9:36 pm #17211286

paulW-65

Background of the issue:
I am trying to force WPML to use one menu for all languages on my site. I am considering using a function file to achieve this.

Symptoms:
The main documentation to force WPML to use one menu for all languages does not work.

Questions:
Is there a way to force WPML to use one menu for all languages using a function file?

July 8, 2025 at 7:08 am #17211950

Bruno Kos
WPML Supporter since 12/2018

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+02:00)

Hi,

By default, WPML automatically creates translations for menus that link to pages, posts, products, and categories. All you need to do is translate the content the menu links to and WPML will handle the rest.

https://wpml.org/documentation/getting-started-guide/translating-menus/

Did you translate them all? If so, do these translated menu items show on the translated languages even if the menus are not translated?

July 8, 2025 at 9:54 am #17212878

paulW-65

Thanks, I only have the Multilingual Blog account type so I don't think I can do this automatically. I'm only translating one page in our site to 40 different languages and for that page I want the same main menu english navigation buttons. How do I do this manually? When I attempt to create a menu for a different language it doesn't allow me to choose the other site pages. And if I change it to the main menu my main english navigation disappears.

July 8, 2025 at 2:28 pm #17214656

Bruno Kos
WPML Supporter since 12/2018

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+02:00)

What if you try something like this (I have not tested it though):

add_filter('wp_get_nav_menu_items', 'force_english_menu_for_all_languages', 10, 3);

function force_english_menu_for_all_languages($items, $menu, $args) {
    // Only run on the frontend and for the specific menu location, e.g., 'primary'
    if (!is_admin() && $args->theme_location === 'primary') {
        // Get the English (default language) menu
        $english_menu = wp_get_nav_menu_object('Main Menu'); // replace with actual menu name
        if ($english_menu && $english_menu->term_id !== $menu->term_id) {
            $items = wp_get_nav_menu_items($english_menu->term_id);
        }
    }
    return $items;
}

Add this snippet to the site’s functions.php file and replace 'Main Menu' with the actual name of the menu you want to show on all languages.

Also make sure that the the theme location (e.g. 'primary') matches your theme’s menu location.

An alternative option would be to hardcode the menu in header.php, something like:

<nav class="main-menu">
  <ul>
    <li><a href="/about">About Us</a></li>
    <li><a href="/services">Services</a></li>
    <li><a href="/contact">Contact</a></li>
    <li><a href="/blog">Blog</a></li>
  </ul>
</nav>

However such approach would offer no support for WordPress menu management (site admins must update HTML manually), nNo dynamic handling of active classes, page highlighting, or accessibility features WP outputs by default.

Something like this it outside of the scope of support work (custom code), so you can check with our https://wpml.org/contractors/ about this.