- สถานะ
- รอผู้พัฒนา
- ปลั๊กอิน/ธีมที่เกี่ยวข้อง
- WP Grid Builder
- แท็กหัวข้อ
- Compatibility
ภาพรวมของปัญหา
เมื่อใช้ Grid Builder ร่วมกับ WPML และ Advanced Custom Fields (ACF) จะพบปัญหาเกี่ยวกับ Facets ที่ใช้ฟิลด์ที่กำหนดเอง แม้ว่าป้ายกำกับฟิลด์ ACF จะได้รับการแปลในส่วนหลังแล้ว แต่กลับไม่แสดงผลในส่วนหน้า
วิธีแก้ปัญหาชั่วคราว
โปรดตรวจสอบให้แน่ใจว่าได้สำรองข้อมูลทั้งหมดของไซต์ของคุณก่อนดำเนินการต่อ
สำหรับฟิลด์ Select
- เปิดไฟล์ functions.php ของธีมของคุณ
- เพิ่มโค้ดต่อไปนี้:
// WPML Workaround for wpmlsupp-11647 function wpml_wpmlsupp11647_translate_facet_choices( $choices, $facet ) { if ( class_exists('Sitepress') ) { foreach ($choices as &$choice) { $string = $choice->facet_name; $textdomain = 'facets'; $string_name = 'Facet: '.substr($string, 0, 20); if ( apply_filters('wpml_default_language', NULL ) == apply_filters( 'wpml_current_language', NULL )) { do_action( 'wpml_register_single_string', $textdomain, $string_name, $string ); } // Apply the translation to the string $choice->facet_name = apply_filters('wpml_translate_single_string', $string , $textdomain, $string_name); } } return $choices; } add_filter( 'wp_grid_builder/facet/choices', 'wpml_wpmlsupp11647_translate_facet_choices', 10, 2 ); - เข้าชมหน้าที่มี Facets ในภาษาต้นฉบับเพื่อลงทะเบียนสตริง
- ไปที่หน้า WPML > การแปลสตริง และแปลสตริง
หมายเหตุ: โค้ดอีกชุดนี้อาจมีประโยชน์ ทั้งนี้ขึ้นอยู่กับวิธีการสร้าง Facets ของคุณ:
// WPML Workaround for compsupp-7453
function wpml_compsupp7453_translate_facet_block_custom_field( $output ) {
if ( class_exists('Sitepress') ) {
if( is_string($output) ) {
$string = $output;
$textdomain = 'facets';
$string_name = 'Facet: '.substr($string, 0, 20);
if ( apply_filters('wpml_default_language', NULL ) == apply_filters( 'wpml_current_language', NULL )) {
do_action( 'wpml_register_single_string', $textdomain, $string_name, $string );
}
// Apply the translation to the string
$output = apply_filters('wpml_translate_single_string', $string , $textdomain, $string_name);
}
}
return $output ;
}
add_filter( 'wp_grid_builder/block/custom_field', 'wpml_compsupp7453_translate_facet_block_custom_field', 99, 2 );