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.


This topic contains 1 reply, has 1 voice.

Last updated by andoni larrañaga 1 year, 11 months ago.

Author Posts
February 6, 2019 at 10:40 am #3165023

andoni larrañaga


Our web has many languages, about 15. But we only show the content for only some.

Is there any possibility to hide some language alternate tags manually?

With this hook I can hide 'it' and 'de' urls, but how can I hide all the line?

add_filter('wpml_alternate_hreflang', 'change_page_hreflang', 10, 2);
function change_page_hreflang($url, $lang_code) {
if (($lang_code != 'it') && ($lang_code != 'de') && ($lang_code != 'pt')) {
return $url;


<link rel="alternate" hreflang="en-us" href="hidden link" />
<link rel="alternate" hreflang="fr-fr" href="hidden link" />
<link rel="alternate" hreflang="de-de" href="" />
<link rel="alternate" hreflang="it-it" href="" />
<link rel="alternate" hreflang="es-es" href="hidden link" />
<link rel="alternate" hreflang="eu" href="hidden link" />
<link rel="alternate" hreflang="pt-br" href="hidden link" />
<link rel="alternate" hreflang="pt-pt" href="hidden link" />
<link rel="alternate" hreflang="ja" href="hidden link" />
<link rel="alternate" hreflang="en-in" href="hidden link" />

I need to remove completely this 2 lines:
<link rel="alternate" hreflang="de-de" href="" />
<link rel="alternate" hreflang="it-it" href="" />


What is the link to your site? hidden link

February 6, 2019 at 11:54 am #3165355

andoni larrañaga

My issue is resolved now.

With this simple hook:

add_filter('wpml_hreflangs', 'custom_lang_code', 10, 1);
function custom_lang_code($hreflang_items){
unset ($hreflang_items['it-it']);
unset ($hreflang_items['de-de']);
return $hreflang_items;

Thank you!