コンテンツへスキップ サイドバーへスキップ

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>