If you are having a notice about writing the .mo files please read this doc

Hi, Amit here, I am the WPML Support Manager, our current ticket queue is high, update your WPML plugins and make sure you meet the minimal requirements for running WPML before reporting an issue please - many tickets are resolved doing that

Please look at our updated list of Known Issues and you can also use our support search to find helpful information and of course review our documentation before opening a ticket.

If you do need to open a ticket please make sure to provide us with all the needed information as described in this page

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.

This topic contains 4 replies, has 2 voices.

Last updated by reijerS 3 weeks, 4 days ago.

Assigned support staff: Bobby.

Author Posts
October 18, 2019 at 4:49 pm #4784661

reijerS

Dear WPML team,

My client website tubble.com is using WPML and is setup in 22 languages/countries. The default language is set to "Worldwide". The hreflang for this language is set to "en" and the default locale is set to "en_EN".

For SEO purposes I would like to add x-default to the hreflang settings to achieve the following end-result:

<link rel="alternate" href="hidden link" hreflang="x-default" />
<link rel="alternate" hreflang="nl-be" href="hidden link" />
<link rel="alternate" hreflang="fr-be" href="hidden link" />
<link rel="alternate" hreflang="cs" href="hidden link" />
<link rel="alternate" hreflang="da" href="hidden link" />
<link rel="alternate" hreflang="de" href="hidden link" />
<link rel="alternate" hreflang="es" href="hidden link" />
<link rel="alternate" hreflang="fr" href="hidden link" />
<link rel="alternate" hreflang="en-ie" href="hidden link" />
<link rel="alternate" hreflang="it" href="hidden link" />
<link rel="alternate" hreflang="nl" href="hidden link" />
<link rel="alternate" hreflang="no" href="hidden link" />
<link rel="alternate" hreflang="de-at" href="hidden link" />
<link rel="alternate" hreflang="pl" href="hidden link" />
<link rel="alternate" hreflang="sv" href="hidden link" />
<link rel="alternate" hreflang="de-ch" href="hidden link" />
<link rel="alternate" hreflang="fr-ch" href="hidden link" />
<link rel="alternate" hreflang="fi" href="hidden link" />
<link rel="alternate" hreflang="en-gb" href="hidden link" />
<link rel="alternate" hreflang="en-us" href="hidden link" />
<link rel="alternate" hreflang="en-au" href="hidden link" />
<link rel="alternate" hreflang="en-nz" href="hidden link" />

I added this code to the functions.php file:

function wps_head_hreflang_xdefault($url, $lang_code) {

	if($lang_code == apply_filters('wpml_default_language', NULL )) {

echo '<link rel="alternate" href="' . $url . '" hreflang="x-default" />'.PHP_EOL;
	}

	return $url;
}
add_filter('wpml_alternate_hreflang', 'wps_head_hreflang_xdefault', 10, 2);

Following this guidance: https://wpml.org/forums/topic/x-default-an-other-issue/#post-1556554

My issue is that now href hidden link is showing twice in my source code, once under the hreflang="x-default" and once under hreflang="en".

<link rel="alternate" href="hidden link" hreflang="x-default" />
<link rel="alternate" hreflang="nl-be" href="hidden link" />
<link rel="alternate" hreflang="fr-be" href="hidden link" />
<link rel="alternate" hreflang="cs" href="hidden link" />
<link rel="alternate" hreflang="da" href="hidden link" />
<link rel="alternate" hreflang="de" href="hidden link" />
<link rel="alternate" hreflang="es" href="hidden link" />
<link rel="alternate" hreflang="fr" href="hidden link" />
<link rel="alternate" hreflang="en-ie" href="hidden link" />
<link rel="alternate" hreflang="it" href="hidden link" />
<link rel="alternate" hreflang="nl" href="hidden link" />
<link rel="alternate" hreflang="no" href="hidden link" />
<link rel="alternate" hreflang="de-at" href="hidden link" />
<link rel="alternate" hreflang="pl" href="hidden link" />
<link rel="alternate" hreflang="sv" href="hidden link" />
<link rel="alternate" hreflang="de-ch" href="hidden link" />
<link rel="alternate" hreflang="fr-ch" href="hidden link" />
<link rel="alternate" hreflang="fi" href="hidden link" />
<link rel="alternate" hreflang="en-gb" href="hidden link" />
<link rel="alternate" hreflang="en-us" href="hidden link" />
<link rel="alternate" hreflang="en" href="hidden link" />
<link rel="alternate" hreflang="en-au" href="hidden link" />
<link rel="alternate" hreflang="en-nz" href="hidden link" />

For testing purposes I made a staging environment of the live site here: hidden link and I have changed the hreflang of Worldwide to "x-default". This seems to work good. But my question to you is if this is the correct way to handle this, or that this might cause any implications in the future.

Looking forward hearing from you,
Reijer

October 18, 2019 at 10:36 pm #4785653

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

Hello,

After examining your source I code I cannot see the duplication of the hreflang for hidden link, but I do see that you might have changed it to hidden link

Overall x-default is not currently supported by WPML at the moment by default which is why the above custom code is required, but it is OK to use as this is the same custom code that many users have reported working for them as well.

For a more custom option, you can also consider contacting one of our certified partners from this link: They can do some custom programming and help on this issue, http://wpml.org/documentation/support/wpml-contractors/

You will get the custom assistance you need to get on with your project. Before doing so please have a look also here: http://wpml.org/documentation/support/wpml-contractors/guidelines-for-people-looking-for-consulting-help/

October 21, 2019 at 2:45 pm #4795317

reijerS

Hey Bobby,

Thank you for getting back to me.

My question would be if I can change the hreflang of the standard language Worldwide, in the language settings from "en" to "x-default"?

As by using the code only, tubble.com is mentioned twice: view-source:hidden link.

Once as <link rel="alternate" hreflang="en" href="hidden link" />
and once as <link rel="alternate" href="hidden link" hreflang="x-default" />

Or will that give any complications?

Or can I achieve displaying the main domain only once by changing the code slightly?

Thanks,
Reijer

October 21, 2019 at 5:13 pm #4796481

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-08:00)

Hello,

By no means, I am an SEO expert but if i correctly understand Google's guidlines regarding the x-default hreflang , the idea is to use it to let Google know that the specific page is not targeting a specific language and can be used as a last resort when no other option is available.

Excerpt is taken by Google's definition:
x-default hreflang attribute value signals to our algorithms that this page doesn’t target any specific language or locale and is the default page when no other page is better suited

Therefore an ideal structure would possibly be to use a Root HTML File for example:

hidden link --> hreflang = x-default
hidden link --> hreflang = en
hidden link etc,
hidden link etc, etc, ....

Please find more information here:
=> hidden link

=> hidden link

I believe you might be Ok using it the way you have it set up or you can even remove the hreflang of one of your languages and replace it by "x-default " within WPML->Languages=>Edit languages but this would not allow for that specific hreflang to be registered and instead replaced by "x-default".

October 24, 2019 at 7:20 pm #4823049

reijerS

My issue is resolved now. Thank you!