WPML

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

เมื่อใช้ SEOPress ร่วมกับ WPML canonical URL สำหรับ เนื้อหาที่ไม่ได้แปล จะไม่ชี้ไปยังภาษาเริ่มต้นเมื่อใช้วิธี “ใช้ภาษาเริ่มต้นเป็นภาษาสำรอง” หรือ “ทำสำเนาเนื้อหา” สิ่งนี้อาจทำให้เกิดปัญหาเนื้อหาซ้ำซ้อนได้

วิธีแก้ปัญหาชั่วคราว

ปัญหานี้ได้รับการแก้ไขแล้ว การอัปเดตเป็นเวอร์ชันล่าสุดจะแก้ปัญหานี้บนไซต์ของคุณ ดังนั้นคุณจึงต้องใช้วิธีแก้ปัญหาชั่วคราวนี้เฉพาะในกรณีที่คุณยังไม่สามารถอัปเดตได้

โปรดตรวจสอบให้แน่ใจว่าได้สำรองข้อมูลไซต์ทั้งหมดก่อนดำเนินการต่อ

  • เปิด: …/wp-content/plugins/wp-seopress/inc/functions/options-titles-metas.php
  • ค้นหาบรรทัดที่ 1022
  • แทนที่:
    PHP
    function seopress_titles_canonical_hook() {
        global $wp;
    
        $current_url = user_trailingslashit(home_url(add_query_arg([], $wp->request)));
    
        if (is_search()) {
            $seopress_titles_canonical = '';
        } elseif (is_paged() && is_singular()) {//Paginated pages
            $seopress_titles_canonical = '';
        } elseif (is_paged()) {
            $seopress_titles_canonical = '';
        } elseif (is_singular()) {
            $seopress_titles_canonical = '';
        } else {
            $seopress_titles_canonical = '';
        }
        //Hook on post canonical URL - 'seopress_titles_canonical'
        if (has_filter('seopress_titles_canonical')) {
            $seopress_titles_canonical = apply_filters('seopress_titles_canonical', $seopress_titles_canonical);
        }
        echo $seopress_titles_canonical . "\n";
    }
  • ด้วย:
    PHP
    function seopress_titles_canonical_hook() {
        global $wp;
    
        $current_url = user_trailingslashit(home_url(add_query_arg([], $wp->request)));
        // WPML Workaround for compsupp-7703
        if (class_exists('SitePress')) {
          $post_ID = get_the_ID();
          $post_type = get_post_type( $post_ID );
          $transl_status = apply_filters( 'wpml_element_translation_type', NULL, $post_ID, $post_type );
          // If the post is not translated, switch to the default language
          if ($transl_status != 1) { 
              $my_default_lang = apply_filters('wpml_default_language', NULL );
              $my_current_lang = apply_filters( 'wpml_current_language', NULL );
              do_action( 'wpml_switch_language', $my_default_lang );
          } 
        }
        if (is_search()) {
            $seopress_titles_canonical = '';
        } elseif (is_paged() && is_singular()) {//Paginated pages
            $seopress_titles_canonical = '';
        } elseif (is_paged()) {
            $seopress_titles_canonical = '';
        } elseif (is_singular()) {
            $seopress_titles_canonical = '';
        } else {
            $seopress_titles_canonical = '';
        }
        // Then switch back to the current language
        if (class_exists('SitePress')) {
            if ($transl_status != 1) {
              do_action( 'wpml_switch_language', $my_current_lang );
            }
        }
        //Hook on post canonical URL - 'seopress_titles_canonical'
        if (has_filter('seopress_titles_canonical')) {
            $seopress_titles_canonical = apply_filters('seopress_titles_canonical', $seopress_titles_canonical);
        }
        echo $seopress_titles_canonical . "\n";
    }

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

ยังคงพบปัญหานี้อยู่หรือไม่

หากการอัปเดตไม่สามารถแก้ไขปัญหานี้ได้ ส่งคำถามถึงฝ่ายสนับสนุน และเราจะตรวจสอบร่วมกับคุณ