- Stato
- In attesa dell’autore
- Plugin/tema correlato
- Yoast SEO
- Tag dell’argomento
- Compatibility
Panoramica del problema
Quando si modificava manualmente la traduzione di una categoria di prodotto da Prodotti > Categorie, Yoast SEO Premium creava erroneamente dei reindirizzamenti 301 anche quando veniva modificata solo la descrizione/il testo della categoria (non lo slug).
I reindirizzamenti creati hanno URL malformati:
Vecchio URL: http://site.com/product-category/test-es-wpml
Nuovo URL: http://site.com/http://es.site.com/product-category/test-es-wpml/ (URL doppio!)
Nota: si tratta di un errore visivo, questi reindirizzamenti non causano problemi di navigazione
Soluzione alternativa
Assicurati di avere un backup completo del tuo sito prima di procedere.
- Apri il file …/wp-content/plugins/wordpress-seo-premium/classes/term-watcher.php.
- Cerca la funzione “protected function get_target_url(”, la troverai intorno alla riga 241.
- Sostituisci:
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 ); }
- Con:
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 ''; }