[Resolved] Lang switcher doesnt get product cat links
This thread is resolved. Here is a description of the problem and solution.
Problem: The client was experiencing issues with the language switcher on their website, where clicking on the language switcher did not navigate to the correct translated product category pages but redirected to the main category page instead. Solution: We discovered that the issue was due to the use of duplicate slugs for the Shop page, Product base, and Product category base. To resolve this, we made the following changes: - Changed the Shop page slug to 'shop'. - Changed the Product category base to 'product-category'. - Set the Product base to '/catalogue/%product_cat%/'. After these adjustments, the language switcher correctly reflected the translated URLs. We also translated these changes into French and German. It is crucial to use unique slugs to avoid similar issues. Additionally, if slugs are changed, it is necessary to resave permalinks and flush all caches.
If this solution does not resolve your issue, or if it seems outdated or irrelevant to your case, 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.
Background of the issue:
I'm trying to use the language switcher on my site hidden link to navigate between translated product category pages. For example, when I'm on the page hidden link and click on FR in the language switcher, I expect it to open hidden link, which is the direct translation of /catalogue/log-houses/. However, it opens /fr/catalogue/ instead.
Symptoms:
The language switcher does not correctly link to the translated product category pages. It redirects to the main category page instead of the specific translated category page.
Questions:
Why does the language switcher not link to the correct translated product category pages?
How can I configure WPML to ensure the language switcher links to the correct translated pages?
Before proceeding further, I'll recommend fixing and trying the following:
Take a full backup of your site and database before proceeding. It is highly advised to try these on a dev or staging site first, so your live site isn't compromised.
1) Update WordPress, WPML, WCML and WooCommerce to latest versions.
2) Deactivate all plugins except WPML, String Translation, WCML and WooCommerce.
3) Switch to a standard theme like 2024 or 2021.
4) Clear all caches, resave permalinks and check for the issue if it still happens.
5) Then start activating plugins one by one while keep checking for the issue. This way you 'll be able to pinpoint a conflict when & where it starts creating the problem.
6) If after activating all plugins you see that it still works fine, then switch to your theme and see if that's causing it.
Please feel free to share your findings and I'll try my best to help you further on the matter.
I need to take a closer look at your site. So I request temporary access (WP-Admin and FTP), preferably to a test site where the problem has been replicated.
Your next answer will be private, to share this information safely.
Also provide detailed steps to reproduce the issue and links to pages in the admin and on the frontend.
IMPORTANT: Please take a complete backup of the site to avoid data loss. I may need to activate/deactivate plugins also.
I was able to dig deeper and found that there are several duplicate slugs are being used. For example, Shop page, Product base and Product category base were using the same slug (catalogue).
Please note that this isn't a WPML issue but a limitation by WordPress, where you can not use the duplicate slug, specially in Store URLs.
Language switcher reflects correct translated URLs now (i.e. French):
- Shop Page: hidden link
- Log Houses category: hidden link
- Cedar Cove product: hidden link
As well as, have also translated these into French and German. This now works fine.
I understand that your desired slug or URLs may not be the same, so you can change these to more appropriate wordings (as needed). HOWEVER, please make sure to use unique slugs.
You may also need to correct the appropriate links used in the menus or elsewhere.
Whenever you change these slugs, remember to resave permalinks and flush all caches.
Thank you, I understand the issue now. But I had to restore it to where it was, used back up for it, now in other then original langs, I'm getting product pages as 404. Tried flushing permalinks, and everything, still same issue, could you check on it?
I checked again and since you've restored the site from previous backup, all the slugs have been restored and these have come to the previous point - the duplicated slugs (watch the hidden link">screen recording for information).