Skip to content

Wrong WPML hreflang tags #22721

@amboutwe

Description

@amboutwe
  • I've read and understood the contribution guidelines.
  • I've searched for any related issues and avoided creating a duplicate issue.

Please give us a description of what happened

WPML added the hreflang to the sitemaps in June 2025. However, one customer reached out to us and mentioned that the hreflang output on the sitemap is incorrect. When he contacted the WPML support team, they stated that it's our output and that we need to fix this issue.

For the URL https://example.com/magazin/, the hreflang meta tag is outputted as

<link rel="alternate" hreflang="en" href="https://example.com/en/magazine/" />
<link rel="alternate" hreflang="de" href="https://example.com/magazin/" />
<link rel="alternate" hreflang="fr" href="https://example.com/fr/magazine/" />
<link rel="alternate" hreflang="it" href="https://example.com/it/magazine/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/magazin/" />

However, when checking the post sitemap, https://example.com/post-sitemap.xml, the source code is as follows:

<url>
<loc>https://example.com/magazin/</loc> ==> CORRECT
<xhtml:link rel="alternate" hreflang="en" href="https://example.com/en/magazin/" /> ==> WRONG
<xhtml:link rel="alternate" hreflang="fr" href="https://example.com/fr/magazin/" /> ==> WRONG
<xhtml:link rel="alternate" hreflang="de" href="https://example.com/magazin/" /> ==> CORRECT
<xhtml:link rel="alternate" hreflang="it" href="https://example.com/it/magazin/" /> ==> WRONG
<xhtml:link rel="alternate" hreflang="x-default" href="https://example.com/magazin/" /> ==> CORRECT
<lastmod>2025-11-11T12:01:04+00:00</lastmod>
</url>

Expected results

Correct WPML hreflang tags

Actual results

Wrong WPML hreflang tags

Technical info

Used versions

  • PHP version: 8.4.13
  • WordPress version: 6.8.3 (multisite: no)
  • WordPress Theme: The7 (Version 12.10.0.1, https://the7.io/)
  • Yoast SEO version: 26.3
  • Relevant plugins in case of a bug: WPML Multilingual CMS v4.8.4 | WPML SEO v2.2.4

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions