WPML
สถานะ
รอผู้พัฒนา
ปลั๊กอิน/ธีมที่เกี่ยวข้อง
Yoast SEO
แท็กหัวข้อ
Compatibility

ภาพรวมของปัญหา

เมื่อแก้ไขการแปลหมวดหมู่สินค้าด้วยตนเองจาก สินค้า > หมวดหมู่ Yoast SEO Premium ได้สร้างการเปลี่ยนเส้นทาง 301 อย่างไม่ถูกต้อง แม้ว่าจะมีการเปลี่ยนแปลงเพียงคำอธิบาย/ข้อความของหมวดหมู่ (ไม่ใช่ slug)

การเปลี่ยนเส้นทางที่สร้างขึ้นมี 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 '';
    }
            

ปัญหาที่ทราบแล้วทั้งหมด →