WPML
Status
Waiting for author
Related plugin/theme
Yoast SEO
Topic tags
Compatibility

Overview of the issue

When manually editing a product category translation from Products > Categories, 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

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

All known issues →