- สถานะ
- แก้ไขแล้ว
ภาพรวมของปัญหา
เมื่อ URL ไม่ถูกต้องในภาษาหนึ่ง WPML จะตรวจสอบว่า URL นี้ถูกต้องในอีกภาษาหนึ่งหรือไม่ หากพบว่าถูกต้อง WPML จะเปลี่ยนเส้นทางผู้เข้าชมไปยัง URL ที่ถูกต้องพร้อมข้อมูลภาษา
อย่างไรก็ตาม การทำงานนี้อาจทำให้เกิดปัญหากับกฎการเขียนซ้ำแบบกำหนดเอง
วิธีแก้ปัญหาชั่วคราว
WPML มีฟิลเตอร์ wpml_is_redirected สำหรับการเปลี่ยนเส้นทางนี้ ต่อไปนี้คือตัวอย่างวิธีการใช้งาน:
/**
* This will prevent redirection in the secondary language for the custom rule:
* '^products/([A-Za-z0-9-]+)/?' => 'index.php?pagename=new-sample&type=$matches[1]'
*/
function wpmlcore_4704_block_redirect( $redirect, $post_id, $q ) {
// Decide on which condition we should prevent the redirection
if ( isset( $q->query_vars['pagename'] ) && 'sample-page' === $q->query_vars['pagename'] ) {
return false;
}
return $redirect;
}
add_filter( 'wpml_is_redirected', 'wpmlcore_4704_block_redirect', 10, 3 );