[Resolved] Woocommerce categories - 404 - rank math compatibility error
This thread is resolved. Here is a description of the problem and solution.
Problem: If you're experiencing a 404 error on your WooCommerce category page due to a compatibility issue with Rank Math, it might be related to the 'Remove parent slugs' option or incorrect slug translations for different languages. Solution: 1. Check if the 'Remove parent slugs' option in Rank Math is causing the issue. A temporary fix can be found in our errata: https://wpml.org/errata/rank-math-seo-remove-parent-slugs-option-causes-category-slug-translation-error-404/ 2. If the issue persists, you may need to adjust the slug translations: - Navigate to WPML > Settings > Slug translations and ensure it is enabled. - Go to WPML > Taxonomy Translation > Product Categories and check the slug translations for each language. - Ensure that the slug translations are either blank or a copy of the original WordPress settings: 'product-category'. 3. If you have modified the Rank Math plugin files as a workaround, ensure to update the slug translations accordingly. You might need to edit the original pages and update the translations in the Advanced Translation Editor.
This solution might be outdated or not applicable to your specific 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 the problem persists, 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 am trying to resolve a 404 error that appears in the search console when accessing a WooCommerce category page. The issue seems to be related to a compatibility error with Rank Math. The problem can be seen on this page: hidden link
Symptoms:
I expected to see the page, but instead, I got a 404 error.
Questions:
How can I fix the 404 error on my WooCommerce category page?
Is there a known compatibility issue between WPML and Rank Math that could cause this error?
Adding some precisions. Screenshot 1, configuration is problematic. Screenshot 2, it works well.
However, I do need configuration 1 for analytics purpose (/product-category/ and /product/ in the urls). The configuration 2 was done a long time ago on another website and I don't want to create a mess with seo.
Thank you for contacting WPML support. While you are waiting for one of my colleagues to take this ticket and work on it, let me provide you with first debugging steps or if I can perhaps help with the issue quickly. As you noted, this is a known issue that our developers are currently working to resolve. Did you apply the workaround from the errata? https://wpml.org/errata/rank-math-seo-remove-parent-slugs-option-causes-category-slug-translation-error-404/
This workaround is coming from a change in the Rank Math file, so their author will need to implement the change in an upcoming release In order for the fix to be permanent. We work closely with Rank Math so I'm fairly certain it will be included in a near future update. In the meantime, adjusting that code should resolve the issue. Please let us know if it does not and we can look further into this.
I found the issue. It is a bug related to "Slug translations".
I disabled this option because obviously I don't need it. However, when testing stuff on the staging website, I found out that some languages still have this slug translation.
Recap:
1/ Turn on "Slug translations" : WPML - Settings - Slug translations
2/ Check the slugs: WPML - Taxonomy Translation - Product Categories
3/ Result:
- Some languages already had their product category slug translated. These languages are all problematic (404 error when trying to open any product category).
- Other languages didn't have any slug translations (French, German). And they work just fine.
4/ The fix:
- Either the slug translation should be blank.
- Either the slug translation should be a copy of the original wordpress settings: product-category.
- Please advice, how to delete the slug translation for all taxonomies when disabling the function "Slug translations". This was my issue. For some reason, I had translations saved with the slug translation option disabled. Maybe I tested the function before and figured out it's useless in my case.
However, disabling the function should also delete the translated slugs. So this is your plugin improvement job.
I will just copy the original slug for the moment, for all languages. Since it works well. And I don't know how to delete this type of translations.
Languages: English (English )Spanish (Español )German (Deutsch )
Timezone: America/Lima (GMT-05:00)
Hello,
Sadly, disabling the option alone will not adapt the slug for all your translations.
You will need to update the translations in this case.
Further slug translations must be saved already inside the translation memory of the Advanced Translation Editor, which means that you will neeed to edit the titles of the original pages, then save the pages, and then update the translations.
About the RankMath SEO issue:
If you apply the workaround of this errata to the Rankmat plugin, it will temporarily solve the issue. The issue needs to be solved on the side of RankMath. Feel free to report it again to them as a reminder.
Open …/wp-content/plugins/seo-by-rank-math/includes/modules/woocommerce/class-permalink-watcher.php file.
The problem is related to the translated taxonomy slugs, which are different from the standard WooCommerce ones:
- /product-category/
- /product-tag/
They should be identical to the default (English) ones and not translated.
You could improve the taxonomy slug translation option by removing the data entered when disabling the option. This was precisely my problem.
I didn't see the error until I re-enabled the slug translation option and viewed the translations on the Taxonomy > Product Category page. The two working languages, French and German, had no slug translations. All other languages were buggy and had translations in Italian, Dutch, Spanish, etc.
After copying the default English slug to the other languages, everything worked.