- ステータス
- 開発者からの返答待ち
- 関連するプラグイン/テーマ
- Yoast SEO
- トピックタグ
- Compatibility
問題の概要
「商品 > カテゴリー」から商品カテゴリーの翻訳を手動で編集した際、(スラッグではなく)カテゴリーの説明/テキストのみを変更した場合でも、Yoast SEO Premiumが誤って301リダイレクトを作成していました。
作成されたリダイレクトのURLは不正な形式になっています。
古いURL: http://site.com/product-category/test-es-wpml
新しいURL: http://site.com/http://es.site.com/product-category/test-es-wpml/ (二重URL!)
注: これは表示上のエラーであり、これらのリダイレクトがナビゲーションの問題を引き起こすことはありません
回避策
作業を進める前に、必ずサイトの完全なバックアップを取得してください。
- …/wp-content/plugins/wordpress-seo-premium/classes/term-watcher.php ファイルを開きます。
- 「protected function get_target_url(」関数を探します。241行目付近にあります。
- 次を:
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 ); }
- 次のように置き換えます:
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 ''; }