WPML
สถานะ
แก้ไขแล้ว
แก้ไขใน
1.2.0
ปลั๊กอิน/ธีมที่เกี่ยวข้อง
Yoast SEO

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

หลังจากมีการเปลี่ยนแปลงครั้งใหญ่ใน Yoast 14.x เมื่อเร็ว ๆ นี้ ผู้ใช้ WPML บางรายพบว่าเนื้อหาของ Yoast ถูกสร้างขึ้นในภาษาเริ่มต้นเสมอ

ตัวอย่างเช่น ในหน้าเว็บที่เป็นภาษารอง อาจเป็นแท็ก “meta” เช่น “og:title” หรือ “og:description” หรือ URL ในเบรดครัมบ์ของคุณ

เรามีวิธีแก้ปัญหาชั่วคราว แต่เนื่องจากลักษณะของปัญหา วิธีนี้อาจไม่ได้ผลสำหรับทุกคน เรากำลังดำเนินการแก้ไขปัญหานี้โดยเร็วที่สุด

หากคุณประสบปัญหาในการแปลเนื้อหาของ Yoast โปรดลองใช้วิธีแก้ปัญหาชั่วคราวด้านล่าง และรอ Yoast Multilingual เวอร์ชันที่เผยแพร่ถัดไปก่อนที่จะติดต่อฝ่ายสนับสนุน

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

เพิ่มโค้ดนี้ลงในไฟล์ functions.php ของธีมของคุณ:

if ( ! is_admin() ) {
	add_filter( 'wpseo_title', 'wpml_wpseo_title', 10, 2 );
	add_filter( 'wpseo_opengraph_title', 'wpml_wpseo_title', 10, 2 );
}

function wpml_wpseo_title( $title, $presentation ) {
	switch ( $presentation->model->object_type ) {
		case 'post-type-archive':
			$key = 'title-ptarchive-' . $presentation->model->object_sub_type;
			break;
		case 'system-page':
			$key = 'title-' . $presentation->model->object_sub_type . '-wpseo';
			break;
		default:
			$key = false;
	}

	if ( $key ) {
		$option = get_option( 'wpseo_titles' );
		if ( isset( $option[ $key ] ) ) {
			$title = wpseo_replace_vars( $option[ $key ], $presentation );
		}
	}

	return $title;
}

if ( ! is_admin() ) {
	add_filter( 'wpseo_metadesc', 'wpml_wpseo_desc', 10, 2 );
	add_filter( 'wpseo_opengraph_desc', 'wpml_wpseo_desc', 10, 2 );
}

function wpml_wpseo_desc( $title, $presentation ) {
	switch ( $presentation->model->object_type ) {
		case 'post-type-archive':
			$key = 'metadesc-ptarchive-' . $presentation->model->object_sub_type;
			break;
		case 'system-page':
			$key = 'metadesc-' . $presentation->model->object_sub_type . '-wpseo';
			break;
		default:
			$key = false;
	}

	if ( $key ) {
		$option = get_option( 'wpseo_titles' );
		if ( isset( $option[ $key ] ) ) {
			$title = wpseo_replace_vars( $option[ $key ], $presentation );
		}
	}

	return $title;
}

add_filter( 'wpseo_save_indexable', function( $indexable ) {
		$args = [
			'element_id'   => $indexable->object_id,
			'element_type' => $indexable->object_type,
		];

		$language_code        = apply_filters( 'wpml_element_language_code', false, $args );
		$indexable->permalink = apply_filters( 'wpml_permalink', $indexable->permalink, $language_code, true );

		return $indexable;
} );

หลังจากเพิ่มโค้ดแล้ว ให้ติดตั้งปลั๊กอิน Yoast Test Helper
ไปที่ Tools > Yoast Test และคลิก “Reset Indexables tables & migrations”
สุดท้าย ไปที่แดชบอร์ดของคุณและคลิกที่ประกาศในหน้าจัดการเว็บไซต์ที่แจ้งให้คุณจัดทำดัชนีไซต์

หากคุณมีคำถามใด ๆ หรือต้องการรายงานปัญหาที่เกี่ยวข้อง โปรดระบุถึงปัญหาที่ทราบแล้วนี้ เพื่อให้ทีมงานของเราสามารถให้บริการจากฝ่ายสนับสนุนแก่คุณได้อย่างมีประสิทธิภาพ

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