Skip Navigation

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.

Our wait time is higher than usual, please make sure you are meeting the minimum requirement - https://wpml.org/home/minimum-requirements before you report issues, and if you can take a look at current Known Issues - https://wpml.org/known-issues/. Thank you.
Sun Mon Tue Wed Thu Fri Sat
5:00 – 13:00 5:00 – 13:00 5:00 – 13:00 5:00 – 13:00 5:00 – 13:00 - -
- - - - - - -

Supporter timezone: Africa/Cairo (GMT+02:00)

This topic contains 4 replies, has 1 voice.

Last updated by daniellaR-2 22 hours, 28 minutes ago.

Assisted by: Osama Mersal.

Author Posts
March 23, 2025 at 4:07 pm #16848984

daniellaR-2

Background of the issue:
I am working on a multilingual WordPress site using WPML. The site is translated, but there is an issue with the main navigation. In the English version, the second navigation item is the WooCommerce Shop Page with 5 product categories: Stokbord, Locata, Duraplas, Tapetile, and Protrack. Hovering over Products on the homepage displays these categories and their products. Clicking on Stokbord takes you to a properly styled page.

Symptoms:
In the German version, the Products menu item is shown as Shop with the 5 categories underneath but no products. Clicking on Stokbord takes you to a different URL: hidden link instead of hidden link.

Questions:
Why are the products not displayed under the categories in the German version?
Why does clicking on Stokbord in the German version lead to a different URL?

March 23, 2025 at 4:08 pm #16849013

daniellaR-2

Hi, can you please add matt@squidd.co.uk to this ticket for updates and notifications.

March 24, 2025 at 10:15 am #16851023

daniellaR-2

Hi, can I get a update on this please. We are due to go live with the German version of the website ASAP.

March 25, 2025 at 2:03 am #16854488

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

Thanks for contacting WPML forums support. I'll be glad to help you today.

First of all, sorry for the late reply; it was due to a higher workload.

1) I'm afraid we can't add emails to the ticket, as our system automatically sends replies to the email in your wpml.org account.

2) Please let me know how this menu is created and translated. Do you use a plugin for the mega menu?

Best regards,
Osama

March 25, 2025 at 8:54 am #16855446

daniellaR-2

Hi Osama,

Our nav is implemented using this code:

<div class="nav--main__wrap <?php if (is_product()) : ?>nav--product <?php endif; ?>cf">
<?php wp_nav_menu(array('menu' => 'Primary Menu', 'menu_class' => 'nav nav--main cf', 'menu_id' => 'nav--main', 'container' => 'ul', 'walker' => new Centriforce_MegaMenu())); ?>
</div>

There is no translation to German in the Menu menu as per the attached screenshots.
I am unable to create a new Translated Menu because the Categories do not appear in the choices.

wpml9.png
wpml8.png
wpml7.png
March 25, 2025 at 5:38 pm #16859319

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

Thanks for your update. I would need to look closely at your site, so I would need to request temporary access (WP-Admin and FTP)
Preferably to a test site where the problem has been replicated.

Your answer will be private, meaning only you and I can access it.

❌ Please back up your database and website ❌

✙ I need your permission to deactivate and reactivate the plugins and themes and change site configurations. This is also why the backup is critical.

✙ I also need your permission to take a local copy of your site to debug the issue without affecting your live site.

Best regards,
Osama

March 26, 2025 at 5:00 pm #16864504

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

Thanks for the access details. I created a German menu, but I couldn't find the code for the mega menu. (hidden link)

In order to translate the menus, please go to WPML-> WP Menu Sync, sync the menus, edit the translated menus in Appearance-> Menus, and save them.

Best regards,
Osama

March 26, 2025 at 9:34 pm #16865677

daniellaR-2

Thanks for all your help so far Osama I really appreciate it,

The code for the MegaMenu is here \themes\centriforce\includes\walkers\Centrforce_MegaMenu.php:

<?php

class Centriforce_MegaMenu extends Walker_Nav_Menu
{
function end_el(&$output, $item, $depth = 0, $args = [], $id = 0) {

$classes = $item->classes;

$output .= "";

if ($depth > 0 && !is_int(array_search('stackable', $classes))) :
//Start menu item flex-wrapper
$output .= '</div>';
endif;

return $output;
}

function start_el(&$output, $item, $depth = 0, $args = [], $id = 0)
{
$classes = $item->classes;
$is_heading_class = in_array("heading", $classes) ? "heading" : "";

if ($depth > 0) :
//Start menu item flex-wrapper
$output .= '<div class="sub-menu-col ' . $is_heading_class . ' ">';
endif;

$output .= "<li class='" . implode(" ", $classes) . "'>";

//Replace page-anchors with a span
if ($item->url && $item->url != '#') {
$output .= 'url . '">';
} else {
$output .= '';
}

$output .= $item->title;

//Close page-anchors with a span
if ($item->url && $item->url != '#') {
$output .= '
';
} else {
$output .= '</span>';
}

//Load category products
if ($item->type_label === 'Category'):
$output .= $this->_render_submenu_products($item);
endif;
}

private function _render_submenu_products($item)
{
$args = array(
'post_type' => 'product',
'post_status' => 'publish',
'ignore_sticky_posts' => 1,
'posts_per_page' => '12',
'tax_query' => array(
array(
'taxonomy' => 'product_cat',
'field' => 'term_id',
'terms' => $item->object_id,
'operator' => 'IN'
),
array(
'taxonomy' => 'product_visibility',
'field' => 'slug',
'terms' => 'exclude-from-catalog',
'operator' => 'NOT IN'
)
)
);
$products = new WP_Query($args);
$output = '';

if (count($products->posts)) :
$output .= '<ul class="sub-menu-products-wrapper">';
foreach ($products->posts as $product) :
$output .= '<li class="sub-menu-product">'
. $product->post_title
. '
';
endforeach;
$output .= '';
endif;

wp_reset_query();
return $output;
}
}

So I can see that the product categories are added but these are still pointing to the wrong URL i.e. hidden link instead of hidden link

And obviously the products under each category are not displaying.

March 27, 2025 at 3:43 am #16866011

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

1) The URL (hidden link) is redirected to the page URL (hidden link).

This also happens to the English product URL. (hidden link)

2) I installed a local copy of your site to check the issue further and deleted the "Centriforce_MegaMenu.php" file, but the megamenu still appeared in English correctly. (Kindly check this hidden link">screenshot)

Please empty this file on your site and check the megamenu.

Kindly note that supporting custom themes is out of our support scope. Please check our support policy.

Best regards,
Osama

March 27, 2025 at 9:44 am #16867205

daniellaR-2

Thanks Osama,

The megamenu is actually in this file \themes\centriforce_new\includes\walkers\Centrforce_MegaMenu.php.

I have updated the code so it is language aware now:

private function _render_submenu_products($item)
{
// Add WPML language parameter
$current_lang = apply_filters('wpml_current_language', NULL);

$args = array(
'post_type' => 'product',
'post_status' => 'publish',
'ignore_sticky_posts' => 1,
'posts_per_page' => '12',
'tax_query' => array(
array(
'taxonomy' => 'product_cat',
'field' => 'term_id',
'terms' => $item->object_id,
'operator' => 'IN'
),
array(
'taxonomy' => 'product_visibility',
'field' => 'slug',
'terms' => 'exclude-from-catalog',
'operator' => 'NOT IN'
)
),
// Add WPML language query
'suppress_filters' => false
);

// Set language before query
do_action('wpml_switch_language', $current_lang);

$products = new WP_Query($args);
$output = '';

if (count($products->posts)) :
$output .= '<ul class="sub-menu-products-wrapper">';
foreach ($products->posts as $product) :
// Get translated product data
$translated_id = apply_filters('wpml_object_id', $product->ID, 'product', true, $current_lang);
$translated_title = get_the_title($translated_id);
$translated_permalink = get_permalink($translated_id);

$output .= '<li class="sub-menu-product">'
. $translated_title
. '
';
endforeach;
$output .= '';
endif;

wp_reset_query();
return $output;
}

To summarise, the Mega Menu works fine in the English version but not the German version where it is not displaying products.

I will use this product (Stokbord® Sheet - Embossed) as an example:

hidden link

When I look in the Categories section (see screenshot) I can see it assigned the Product category of Stokbord.

Using the WPML Translation Editor there is no way of ensuring the correct Category is assigned to the Product in German.

I assume this uses the Taxonomy translations (screenshot attached)

However, when I visit this page: (see screenshot)
hidden link

And click on the pencil icon for the German translation of Stokbord, the screen shows the slug as stokbord-de. If i change this to stokbord it saves but changes it back.
See screenshot.

If you visit this page:
hidden link

It is a correctly rendered version of the Stokbord brand page which uses the brand.php page template.

However clicking on the Produkte -> Stokbord menu option navigates you to :

hidden link

Which is the incorrect page and uses the woocommerce product-cat.php template.

wpml16.png
wpml15.png
wpml12.png
wpml11.png