Panoramica del problema
Quando si modificava manualmente la traduzione di una categoria di prodotto da ProdottiCategorie, 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
Questo problema è stato risolto. L’aggiornamento all’ultima versione risolve il problema sul tuo sito, quindi hai bisogno di questa soluzione alternativa solo se non puoi ancora aggiornare.
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:PHP
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:PHP
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 ''; }