WPML
Statut
En attente de l’auteur
Extension/thème associé
Yoast SEO
Étiquettes de sujet
Compatibility

Aperçu de l’anomalie

Lors de la modification manuelle d’une traduction de catégorie de produit depuis Produits > Catégories, Yoast SEO Premium a créé à tort des redirections 301, même lorsque seuls la description/le texte de la catégorie ont été modifiés (et non le slug).

Les redirections créées comportent des URL mal formées :

Ancienne URL : http://site.com/product-category/test-es-wpml

Nouvelle URL : http://site.com/http://es.site.com/product-category/test-es-wpml/ (double URL !)

Remarque : Il s’agit d’une erreur visuelle, ces redirections ne causent pas de problèmes de navigation

Solution de contournement

Veuillez vous assurer d’avoir une sauvegarde complète de votre site avant de continuer.


  • Ouvrez le fichier …/wp-content/plugins/wordpress-seo-premium/classes/term-watcher.php.

  • Recherchez la fonction « protected function get_target_url( », vous la trouverez vers la ligne 241.

  • Remplacez :
    protected function get_target_url( $tag, $taxonomy ) {
        // Get the term link.
        $term_link = get_term_link( $tag, $taxonomy );
    
        // Return early if the term link is not a string, i.e. a WP_Error Object.
        if ( ! is_string( $term_link ) ) {
            return '';
        }
    
        return str_replace( home_url(), '', $term_link );
    }
            


  • Par :
    protected function get_target_url( $tag, $taxonomy ) {
        // Get the term link.
        $term_link = get_term_link( $tag, $taxonomy );
    
        // Return early if the term link is not a string, i.e. a WP_Error Object.
        if ( ! is_string( $term_link ) ) {
            return '';
        }
    
        // Extract the path to handle WPML subdomain URLs (matches post-watcher behavior).
        $url = wp_parse_url( $term_link );
        if ( is_array( $url ) && isset( $url['path'] ) ) {
            return $url['path'];
        }
    
        return '';
    }
            

Toutes les anomalies connues →