דלג לתוכן דלג לסרגל צד

Waiting for author

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

השאר תגובה

אנא הישאר בנושא והיה מכבד כלפי אחרים. אם אתה זקוק לעזרה בנושאים שאינם קשורים לפוסט זה, השתמש בפורום התמיכה שלנו כדי להתחיל צ'אט או לשלוח כרטיס.

אתה יכול להשתמש בתגים אלה:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>