Passer la navigation

Open

Reported for: WPML SEO 2.2.0

Topic Tags: Compatibility

Overview of the issue

When using Yoast SEO with WPML SEO, you might experience an issue where hreflang tags for hidden languages still appear in the sitemap’s source code as alternate language references, even though the posts in hidden languages are correctly excluded from the sitemap index.

Workaround

Please, make sure of having a full site backup of your site before proceeding.

  • Open the …/wp-content/plugins/wp-seo-multilingual/classes/Shared/Sitemap/BaseAlternateLangHooks.php file.
  • Look for the function addAlternateLangData starting at line 59.
  • After this line:
    list( $elements, $getPermalink, $isIndexable ) = $this->getEntryHelpers( $type, $obj );
            
  • Insert the following block of code:
    // WPML Workaround for wpmlwpseo-350 - 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] );
            }
        }
    }
            

Laisser une réponse

Veuillez rester dans le sujet et être respectueux envers les autres. Si vous avez besoin d'aide pour des problèmes non liés à ce message, utilisez notre Forum de support pour commencer une discussion ou soumettre un ticket.

Vous pouvez utiliser ces balises :
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>