Home›Support›English Support›[Resolved] Translated product category slugs in Swedish in translated sub categories menu.
[Resolved] Translated product category slugs in Swedish in translated sub categories menu.
This thread is resolved. Here is a description of the problem and solution.
Problem: The client was experiencing an issue where after switching languages using the header language switcher and selecting a child category from the sidebar menu, all other child category menus displayed incorrect product_cat slugs in their links. The problem seemed to be related to the WordPress 6.5 localization changes but was resolved after updating WPML Multilingual CMS from 4.6.9 to 4.6.10.
Solution: We recommended the following steps: 1. Check for any code-based rules applied to the categories and remove them if possible. 2. Remove any untranslated elements added in the code for the Archive page and revert any custom changes to display WooCommerce's default Category archive. 3. Add the default Product Category widget in the sidebar and re-evaluate the situation. 4. If using the
get_queried_object_id()
function to display terms, use the wpml_object_id hook to ensure the correct taxonomy ID is retrieved in each language.
We also noted that support for issues arising from custom themes or code modifications is beyond our scope, and suggested consulting with the theme developer or hiring a WPML-experienced developer from our contractors.
If the solution provided here is not relevant to your case, either because it's outdated or not applicable, 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 the issue persists, please do not hesitate to open a new support ticket with us.
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.
Link to a page where the issue can be seen: hidden link
Steps:
1. hidden link - opens Estonian page.
2. Switch to Suomi/English from the header language switcher.
3. On English home page click on "BUY ONLINE" button, this will take you to Shop page.
4. On the left you see sidebar which contains menu.
5. Select any child category from the menu.
6. Now after arriving in the child category you selected, all the other child category menus have Swedish product_cat slug in their link, which is wrong.
3) Remember to translate the text in String Translation if the menu is a custom link (info found on the link above as well).
4) If nothing works, then please let us know if this menu is added with a block, widget or something specific so we can try to understand what to do next.
1. Added
2. There's nothing to resync - they're already synced. Not automatically translated.
3. Not a custom link
4. Still not working.
It's added as a Widget. The Widget contains the default WordPress menu widget.
It seems that this issue is only happening when the user is not logged in. When the user is logged in there's no issues.
I have taken over this ticket and would be happy to assist you further in this matter.
After examining the issue, it's clear that the issue affects all languages. Only the slug for the category currently being viewed remains consistent; the slugs for all other categories are being replaced by slugs from another language.
This issue appears to be the result of a conflict that is causing the category slugs to change. Could you please conduct a conflict test on your site to see if it helps in solving the issue?
To proceed with the conflict test, take a backup before the test. After that, please temporarily deactivate all plugins except for WPML, String Translation, WooCommerce, and WooCommerce Multilingual plugins. Then, verify whether the slugs for the categories still change on the Products page.
If this action resolves the issue, gradually reactivate the other plugins one by one. After each activation, refresh the Products page and observe the category slugs. This process will help you identify if a specific plugin is causing the slug changes.
Please let me know how it goes. I will be happy to help if you need further assistance in this matter.
Did de-activate all plugins except the ones mentioned by you. This did not solve the issue.
A bit additional information:
It was working fine before. It happened after our customer was modifying Swedish menu (removing and adding product categories). After saving the menu it broke the product category slugs in the menus in other languages.
Hello There,
Thank you for the update and for sharing the information.
While reviewing the WPML Debug Info, I noticed the "Product" post type's translation preference is set to "Translatable - use translation if available or fallback to default language." This setup could potentially be influencing the issue, as it allows for the display of default content in the absence of translations.
Would you please change the translation preference for the Product post type to "Translatable - only show translated items" by going to "WPML > Settings ↳ Post type Translation" and check whether the issue still persists or not? After changing the setting, you can just save the permalink structure by going to "Settings > Permalinks" and then check.
If the issue persists, a closer inspection will be required to understand the root cause of the issue.
I would like to request temporary access (wp-admin and FTP) to your site to take a better look at the issue. It would be better to have a testing site where the issue is replicated.
You will find the needed fields below the comment area when you log in to leave your next reply. The information you will enter is private which means only you and I can see and have access to it.
Maybe I'll need to replicate your site locally. For this, I’ll need to temporarily install a plugin called “Duplicator” or "All in One WP Migration" on your site. This will allow me to create a copy of your site and your content. Once the problem is resolved I will delete the local site. Let me know if this is ok with you.
IMPORTANT
-Please backup site files and database before providing us access.
-If you do not see the wp-admin/FTP fields this means your post & website login details will be made PUBLIC. DO NOT post your website details unless you see the required wp-admin/FTP fields. If you do not, please ask me to enable the private box. The private box looks like this: hidden link
Additional information about the issue!
Not only the url slug is wrong but also some strings translated in String translation will turn into default language.
For example here: hidden link
In the header you see the following strings:
"Leia sobiv toode"
"Tasuta tarne al. 100€"
"Saadame kauba tasuta kohale üle Eesti!"
They're the default language strings (Estonian). When you go to any other page they'll turn into the translated language.
So it's not affecting only url slugs but also strings translated via string translation.
Hello There,
Thank you for sharing the access information.
Upon closer review, it's clear that the categories displayed in the Sidebar are not solely managed through a Widget. There have been specific code modifications or additions within your custom Theme that might have impacted how these categories are shown. The root of the issue seems to be linked to the permalinks, which are not being correctly refreshed when the terms are queried leading to the problem you're experiencing.
I've also noticed that disabling ACF also results in the disappearance of categories from the Archive, indicating that there might be specific rules affecting this behavior.
Could you please try the following steps to see if the issue persists?
1. Check for any code-based rules applied to the categories and remove them if possible.
2. Remove any elements added in the code for the Archive page that haven't been translated. If possible, revert any custom changes that you made and display WooCommerce's default Category archive.
3. Add the default Product Category widget in the sidebar and re-evaluate the situation.
If you're using the `get_queried_object_id()` function to display terms, consider using the `wpml_object_id` hook to ensure the correct taxonomy ID is retrieved in each language. For more details about its usage, see this documentation: https://wpml.org/wpml-hook/wpml_object_id/
Please be informed that providing support for the issues arising from custom themes or code modifications is beyond the scope of our support. Therefore, I can only offer guidance within our scope. It will be better to consult with your theme developer regarding this matter, specifically adjust the multilingual support where is needed.
For direct code assistance, you might consider hiring a WPML-experienced developer from here: https://wpml.org/contractors/
Addressing the Category display issue might also resolve the translation problem with the Header text. If the Header issue remains, I request you to open a new ticket for that specific problem, as we aim to focus on one issue at a time, allowing our support team to provide more targeted assistance.
I hope you can understand. Please keep me posted on your progress, and if there's anything within our support boundaries that you need help with, I'll do my best to assist.
1. One code-based rule is applied to the categories in the wordpress main query (pre_get_posts) but there's no conflict with that. We removed this and confirmed this.
2. There's no conflicting code in the archive page, we've already confirmed this.
3. We don't use Product category widget. We use WordPresses default Menu Widget - no modification have been done to this.
I've been doing debugging myself and what I've discovered so far is that when WooCommerce Multilingual & Multicurrency plugin is active the problem exists. When I disable it the problem disappears. So the cause is in the WooCommerce Multilingual & Multicurrency plugin.
We've done no changes to the theme that we've developed, prior to the issue appearing. It was working fine. The customer just went to modify the Swedish product category menu, after saving the menu it broke everything.
There's no conflicting code in our custom theme - we've removed everything and the issue persists. Only thing that works is disabling Multilingual & Multicurrency plugin.
We're using get_queried_object_id() in few places but in no way it should cause conflict - nothing related to the way the menu is displayed. As everything was working fine before.
Update:
After updating WPML Multilingual CMS 4.6.9 to 4.6.10 the issue seems to be resolved.
Seems like the issue is related to the WordPress 6.5 new localization changes that have been fixed in WPML Multilingual CMS 4.6.10 and WPML String Translation 3.2.10.
Right now it's fixed and seems to be working as it was before.