So just connect this pages if this is important for you. If I go to one of my pages for example http://lloc.de/about I see this in the header which is correct I think:
<link rel="alternate" hreflang="de" href="http://lloc.de/about" />
<link rel="alternate" hreflang="it" href="http://lloc.it/chi-sono" />
Cheers,
Dennis.
thank you Dennis, do you know which php file generates the URLs for the flags?
I guess it could be solved by adding $pagename after site URL … fex.
$pagename = $post->post_name;
But you are the one that wanted to disactivate this filter function.
https://ww.wp.xz.cn/support/topic/disable-hreflang-in-header?replies=3
Could you please explain what you are doing?
Google does not recommend use of rel=canonical, instead you should use x-default …
My hreflangs looks like:
<link rel=”alternate” hreflang=”de-DE” href=”<?php echo network_site_url(); ?><?php echo $pagename; ?>” />
…
<link rel=”alternate” hreflang=”de-DE” href=”https://www.mydomain.tld/” />
<link rel=”alternate” hreflang=”de-CH” href=”https://www.mydomain.tld/” />
<link rel=”alternate” hreflang=”de-FR” href=”https://www.mydomain.tld/” />
<link rel=”alternate” hreflang=”de-BE” href=”https://www.mydomain.tld/” />
<link rel=”alternate” hreflang=”de-NL” href=”https://www.mydomain.tld/” />
<link rel=”alternate” hreflang=”de-GB” href=”https://www.mydomain.tld/” />
<link rel=”alternate” hreflang=”de-US” href=”https://www.mydomain.tld/” />
<link rel=”alternate” hreflang=”en-DE” href=”https://www.mydomain.tld/en/” />
<link rel=”alternate” hreflang=”en-CH” href=”https://www.mydomain.tld/en/” />
<link rel=”alternate” hreflang=”en-FR” href=”https://www.mydomain.tld/en/” />
<link rel=”alternate” hreflang=”en-BE” href=”https://www.mydomain.tld/en/” />
<link rel=”alternate” hreflang=”en-NL” href=”https://www.mydomain.tld/en/” />
<link rel=”alternate” hreflang=”en-GB” href=”https://www.mydomain.tld/en/” />
<link rel=”alternate” hreflang=”en-US” href=”https://www.mydomain.tld/en/” />
<link rel=”alternate” hreflang=”fr-DE” href=”https://www.mydomain.tld/fr/” />
<link rel=”alternate” hreflang=”fr-CH” href=”https://www.mydomain.tld/fr/” />
<link rel=”alternate” hreflang=”fr-FR” href=”https://www.mydomain.tld/fr/” />
<link rel=”alternate” hreflang=”fr-BE” href=”https://www.mydomain.tld/fr/” />
<link rel=”alternate” hreflang=”fr-NL” href=”https://www.mydomain.tld/fr/” />
<link rel=”alternate” hreflang=”fr-GB” href=”https://www.mydomain.tld/fr/” />
<link rel=”alternate” hreflang=”fr-US” href=”https://www.mydomain.tld/fr/” />
<link rel=”alternate” hreflang=”x-default” href=”https://www.mydomain.tld/” />
but in content pages all language flags points to home, except the selected language flag shows a complete page URL …
I’m sure that you’ll understand that you should debug your own functionalities at your own. I already indicated you the function that will give you an example how to do this: https://github.com/lloc/Multisite-Language-Switcher/blob/master/MultisiteLanguageSwitcher.php#L230
In that function is also a filter which can be used to overrdide the value of a language:
$hreflang = (string) apply_filters( 'msls_head_hreflang', $language );
A filter like this would return always the complete language instead of 2 chars like ‘de’:
function my_msls_head_hreflang( $language ) {
return $language;
}
add_filter( 'msls_head_hreflang', 'my_msls_head_hreflang' );
Simple, isn’t it? You don’t need to reinvent the wheel here. This would be all you need. No remove of the filter is needed, no other functions … just a small filter like this.
If you think that the plugin should return ‘x-default’ instead of ‘alternate’ in some cases then make a feature request here:
https://github.com/lloc/Multisite-Language-Switcher/issues