Chuyển đến nội dung Chuyển đến thanh bên

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

Để lại trả lời

Vui lòng giữ đúng chủ đề và tôn trọng người khác. Nếu bạn cần trợ giúp với các vấn đề không liên quan đến bài đăng này, hãy sử dụng Diễn đàn Hỗ trợ của chúng tôi để bắt đầu trò chuyện hoặc gửi vé hỗ trợ.

Bạn có thể sử dụng các thẻ này:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>