Skip to content Skip to sidebar

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.

Sun Mon Tue Wed Thu Fri Sat
- 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 -
- 12:00 – 16:00 12:00 – 16:00 12:00 – 16:00 12:00 – 16:00 12:00 – 16:00 -

Supporter timezone: Europe/Zagreb (GMT+02:00)

This topic contains 3 replies, has 0 voices.

Last updated by Dražen 3 days ago.

Assisted by: Dražen.

Author Posts
May 6, 2026 at 7:48 am #18016001

tommyJ-4

Hi WPML support,

I'd like to report a bug with WPML SEO 2.2.5 and its integration with Yoast SEO Premium on a WooCommerce site.

Setup:
- WPML SEO 2.2.5
- Yoast SEO Premium (latest)
- WooCommerce with product categories in the URL structure
- Languages: Swedish (original) and English
- Product base slug: Swedish = "produkt", English = "product" (correctly configured in WPML slug translation)

Problem:
When Yoast generates the product sitemap, English product URLs are generated using Swedish category slugs instead of their translated English equivalents. For example:

Sitemap generates: /en/product/matinstrument/temperaturmatare/temperaturgivare/product-name/
Correct URL should be: /en/product/measuring-instruments/temperature-gauges/temperature-probes/product-name/

This causes Google Search Console to report indexing issues due to redirects, since the incorrect URLs redirect to the correct ones.

Root cause:
The WPML language filter does not appear to be active when Yoast iterates through products to build the sitemap. As a result, get_permalink() falls back to the original language (Swedish) for category slugs, even though the post type base slug ("product") is correctly translated.

Workaround:
The only working solution was a mu-plugin that manually switches the WPML language context for each sitemap entry via wpml_switch_language before calling get_permalink():

add_filter( 'wpseo_sitemap_entry', function( $entry ) {
if ( ! isset( $entry['loc'] ) ) return $entry;
if ( strpos( $entry['loc'], '/en/' ) === false ) return $entry;

$post_id = url_to_postid( $entry['loc'] );
if ( ! $post_id ) return $entry;

$english_id = apply_filters( 'wpml_object_id', $post_id, 'product', true, 'en' );
if ( ! $english_id ) return $entry;

do_action( 'wpml_switch_language', 'en' );
$correct_url = get_permalink( $english_id );
do_action( 'wpml_switch_language', 'sv' );

if ( $correct_url ) $entry['loc'] = $correct_url;
return $entry;
}, 10, 1 );

This should not be necessary if WPML SEO correctly sets the language context during Yoast's sitemap generation.

Please investigate whether this is a known issue and if a fix is planned for a future version of WPML SEO.

Best regards,
Tommy
Nordtec Instrument AB

May 6, 2026 at 8:09 am #18016138

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hello Tommy,

I have just tested this on a fresh test site and it works fine there, so I am currently unable to reproduce the same issue.

hidden link

Please login using the next link and try to reproduce the issue there, in case I missed some specific step:

hidden link

If it still works correctly on the test site, then the issue is most likely related specifically to your website setup, and we would need to investigate further, preferably on a staging site.

Please let me know how it goes.

Regards,
Drazen

May 13, 2026 at 6:11 am #18031697

tommyJ-4

I just wanted you to know that I have reported this issue to Yoast as well, and here is the answer I got from them, that indicates that there is indeed a problem:

Hi Tommy,

Thanks for your detailed report and for sharing your workaround with us. Indeed, Yoast SEO generates a single sitemap across all languages, so the /en/sitemap_index.xml returning a 404 error is the expected behaviour.

To the main issue, I understand that English URLs in the sitemap use Swedish category slugs. Each URL in the sitemap should be fully correct and language-consistent. We’re aware of compatibility issues between Yoast SEO and WPML, particularly relating to sitemap URLs. While we don’t have a specific fix or timeline to share at the moment, these types of issues are being monitored and reviewed by our product team, and improvements in this area are being considered.

In the meantime, I'm glad you found a workaround using wpseo_sitemap_entry that enforces the correct language context. If you’re open to it, you’re welcome to submit a bug report ( hidden link ) and include your findings and workaround. Contributions like this are very helpful, and if you’d prefer, you could also explore submitting a pull request.

May 13, 2026 at 6:15 am #18031700

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hello Tommy,

Thank you for the update and for sharing the response from Yoast SEO.

I understand their reply, and it is useful to know they are aware of some compatibility-related sitemap URL issues. However, from our side, I am still unable to reproduce the same problem on a clean test installation, so at the moment I cannot officially confirm this as a general WPML bug.

As mentioned previously, please also try reproducing the issue on the sandbox site I shared, in case there is a specific step or condition I may be missing.

If the issue does not happen there either, then it is very likely related to something specific in your website configuration, plugin setup, data, or environment.

In that case, the best next step would be to investigate this further on a staging copy of your website, where we can safely debug and compare the behavior in more detail.

Please let me know the results from the sandbox test, and we can continue from there, if you are intreasted.

Regards,
Drazen