|
Plugins involved
WPML Multilingual & Multicurrency for WooCommerce
WPML Core
Yoast SEO
Problem summary
We are seeing incorrect product category URLs generated only in the Yoast XML sitemap for translated (German) products.
After investigation, this issue does not originate from Yoast SEO. The root cause appears to be within WPML Multilingual & Multicurrency for WooCommerce, specifically how category links are filtered when generating sitemap URLs.
Technical findings
The issue is caused by the function:
translate_product_post_type_link_product_cat_when_display_as_translated()
When this function runs during sitemap generation, it:
Overrides the correct German primary category
Uses the wpml_object_id filter
Returns uncategorized as the primary category for German products
This results in incorrect product URLs inside the Yoast product sitemap
However:
When the same function runs on the frontend, it behaves correctly
The correct translated (German) primary category is returned
The issue happens only in the sitemap context
This strongly suggests a context-related issue in how WPML handles product category resolution when Yoast builds sitemap links.
Expected behavior
German products in the Yoast sitemap should use their correct translated primary product category
The sitemap URLs should match what is output on the frontend
Actual behavior
German product sitemap URLs contain /product-category/uncategorized/
This happens even though the product has a valid translated category
Frontend URLs are correct; only sitemap URLs are wrong
Additional context / configuration
This issue occurs when the following WPML setting is enabled:
WPML → Settings → Post Type Translation
Product is set to:
“Translatable – use translation if available or fallback to default language”
Changing this setting affects whether the issue occurs.
Summary
This is not a Yoast SEO bug
The issue lies in WPML’s WooCommerce Multilingual handling of product category links
Specifically, translate_product_post_type_link_product_cat_when_display_as_translated() behaves inconsistently between:
Sitemap generation
Frontend rendering
We believe WPML should avoid overriding the primary category with uncategorized when generating sitemap URLs.
|