Skip Navigation

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.

Tagged: 

This topic contains 2 replies, has 0 voices.

Last updated by anna-stanczykT 2 days, 17 hours ago.

Assisted by: Bruno Kos.

Author Posts
July 7, 2025 at 7:35 am #17206570

anna-stanczykT

Background of the issue:
I am trying to resolve an issue with the WPML SEO plugin after updating to versions 2.2.0 and 2.2.1. The problem is related to the Yoast SEO sitemaps showing hreflang tags for hidden or disabled languages. On my website, we have four languages: EN, PL (active), and ES, FR (hidden/disabled). I don't want to remove ES and FR completely because we might use them in the future. The issue can be seen on this page: hidden link. Here is the code snippet from the sitemap: hidden link 2023-03-07T12:28:20+00:00 hidden link

Symptoms:
The sitemap shows hreflang="es" and hreflang="fr" even though these languages are hidden or disabled. Additionally, there are two /fr/fr/ in the URL, and Ahrefs reports 1200 404 errors because of this.

Questions:
Why are hreflang tags for hidden or disabled languages appearing in the sitemap?
How can I prevent hidden or disabled languages from showing in the sitemap?

July 7, 2025 at 3:15 pm #17209843

Bruno Kos
WPML Supporter since 12/2018

Languages: English (English ) German (Deutsch ) French (Français )

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

This has been escalated to our 2nd tier team team and may take some debugging time, I'll get back to you as soon as I have any news or questions for you.

July 8, 2025 at 12:51 pm #17213955

Bruno Kos
WPML Supporter since 12/2018

Languages: English (English ) German (Deutsch ) French (Français )

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

As a temporary workaround, you can make a direct modification to the plugin's codebase. Please follow these steps carefully:

1. Open the following file in your plugin directory:

/plugins/wp-seo-multilingual/classes/Shared/Sitemap/BaseAlternateLangHooks.php

2. Locate the `addAlternateLangData` function, which starts around line 59.

3. Immediately after this line:

list( $elements, $getPermalink, $isIndexable ) = $this->getEntryHelpers( $type, $obj );

4. Insert the following block of code:

// Exclude hidden language posts
global $sitepress;
$hidden_languages = $sitepress->get_setting( 'hidden_languages', [] );

if ( $elements && !empty($hidden_languages) ) {
	foreach ( $elements as $lang => $element ) {
		if ( in_array( $lang, $hidden_languages ) ) {
			unset( $elements[$lang] );
		}
	}
}

This change will ensure that any posts in hidden languages are excluded from the alternate language data in your sitemap.

The permanent fix will likely end up in the next version of our WPML SEO plugin.

July 9, 2025 at 6:15 am #17216857

anna-stanczykT

Thank you. It helped.