Overview of the Issue
When manually editing a product category translation from ProductsCategories, Yoast SEO Premium incorrectly created 301 redirects even when only the category description/text was changed (not the slug).
The created redirects has malformed URLs:
Old URL: http://site.com/product-category/test-es-wpml
New URL: http://site.com/http://es.site.com/product-category/test-es-wpml/ (double URL!)
Note: This is a visual error, these redirections do not cause navigation issues
Workaround
This issue is fixed. Updating to the latest version solves it on your site, so you only need this workaround if you can’t update yet.
Please, make sure of having a full site backup of your site before proceeding.
- Open the …/wp-content/plugins/wordpress-seo-premium/classes/term-watcher.php file.
- Look for the function “protected function get_target_url(” , You’ll find it around line 241.
- Replace: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 ); }
- With: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 ''; }