WPML
Status
Aguardando o autor
Plugin/tema relacionado
Yoast SEO
Tags de tópico
Compatibility

Visão geral do problema

Ao editar manualmente a tradução de uma categoria de produto em Produtos > Categorias, o Yoast SEO Premium criava incorretamente redirecionamentos 301 mesmo quando apenas a descrição/texto da categoria era alterado (e não o slug).

Os redirecionamentos criados têm URLs malformadas:

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

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

Observação: Este é um erro visual, esses redirecionamentos não causam problemas de navegação

Solução alternativa

Por favor, certifique-se de ter um backup completo do seu site antes de prosseguir.


  • Abra o arquivo …/wp-content/plugins/wordpress-seo-premium/classes/term-watcher.php.

  • Procure a função “protected function get_target_url(”, você a encontrará por volta da linha 241.

  • Substitua:
    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 );
    }
            


  • Por:
    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 '';
    }
            

Todos os problemas conhecidos →