Support » Plugin: Multisite Language Switcher » “Alternate” tags missing on homepage

  • Resolved peterbisset

    (@peterbisset)


    Hi,

    WordPress version 5.4 using cctlds with domain mapping
    MSLS Version 2.4.2

    I’ve been using your plugin for about 4 years, amazing job thank you so much!

    I’ve recently been auditing my SEO and realised that the <link rel=”alternate”> tags for the translated pages do not appear in the head of the homepage of each of the sites. Instead there is a <link rel=”alternate” hreflang=”x-default”> tag for the page itself.

    The language switcher on the homepage still works and the pages are linked up in the admin dashboard.

    They are however working perfectly on the internal pages of each of the sites.

    Could this be a plugin conflict or is it a bug in MSLS?

    Regards,
    Peter

Viewing 12 replies - 1 through 12 (of 12 total)
  • I’m having the exact same issue. Rolling back to 2.3.0 works fine for me

    Thanks that worked, there is obviously a bug in the latest versions?

    There is still an issue however; I have independent websites for Austria and Germany and the alternate tags both display hreflang=”de” where as they should be hreflang=”de-AT” hreflang=”de-DE” respectively. They are both configured in the language settings that way.

    Try putting this in functions.php

    // Adjust to the correct hreflang tags in the alternate tags
    function my_msls_head_hreflang( $language ) {
    if ( ‘de_DE’ == $language ) {
    $language = ‘de-DE’;
    }
    if ( ‘de_AT’ == $language ) {
    $language = ‘de-AT’;
    }
    return $language;

    }
    add_filter( ‘msls_head_hreflang’, ‘my_msls_head_hreflang’ );

    Plugin Author Dennis Ploetner

    (@realloc)

    I can confirm that I tracked down the bug and I’ll deploy very soon the next update.

    Plugin Author Dennis Ploetner

    (@realloc)

    Version 2.4.3 is now in the plugin directory. You could probably use also a more generalized version for the filter:

    function my_msls_head_hreflang( $language ) {
        return str_replace( '_', '-', $language );
    }
    add_filter( ‘msls_head_hreflang’, ‘my_msls_head_hreflang’ );

    Cheers!

    I’ve updated the plugin and the alternate tags now appear… thank you!

    On the other issue with the tags; I tried placing both of these suggestions in my functions.php but neither had an affect on changing “de” to “de-DE”. I have quite a few of these like “ch-FR”, “lu-FR”, “fr-FR” etc. etc. so it’s important that this is correct from an SEO perspective.

    While I was checking I also noticed that the default <html class=”no-js” lang=”cs” itemscope=”itemscope” itemtype=”https://schema.org/WebPage”&gt; and
    <meta http-equiv=”Content-Language” content=”cs”> were set to the admin website for the multisite setup (Czech). Are these generated by this plugin or will this be a seperate issue?

    Plugin Author Dennis Ploetner

    (@realloc)

    The plugin doesn’t change the <html> or the <meta> in question. This could come from the theme (just a long shot).

    I will look for a solution for tags. Maybe I can create something useful in the blog-collection.

    Ok thank you I will take a look at where this is being generated from.

    With regard to the “alternate” tags, I am more than happy to pay if this is difficult to develop as a feature.

    peterbisset, is it the HTML lang tags you’re trying to change? if so, try this:

    // Change de to de-DE
    if ( get_locale() == 'de_DE' ) {
    	// Make this variable global
    	global $__language_attribute;
    
    	// Set the language we want to use
    	$__language_attribute = 'de-DE'; 
    
    	// Listen for the language filter
    	add_filter('language_attributes', '__language_attributes_use_global');
    
    	function __language_attributes_use_global($lang){
    	   global $__language_attribute;
    	   return "lang=\"$__language_attribute\"";
    	}
    }

    Thanks danneniko, I put that in my functions.php but it didn’t seem to work?

    Plugin Author Dennis Ploetner

    (@realloc)

    The upcoming version 2.4.4 offers a better solution for the hreflang links that should work good for you. You could test the dev version on Github: https://github.com/lloc/Multisite-Language-Switcher

    Amazing thank you!

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘“Alternate” tags missing on homepage’ is closed to new replies.