- สถานะ
- แก้ไขแล้ว
- รายงานสำหรับ
- WPML Multilingual CMS 4.6.15
- แก้ไขใน
- WPML 4.7.5
- ปลั๊กอิน/ธีมที่เกี่ยวข้อง
- Elementor
- แท็กหัวข้อ
- Compatibility
ภาพรวมของปัญหา
เมื่อใช้ วิดเจ็ตรูปภาพของ Elementor หน้าเว็บเวอร์ชันที่แปลอาจยังคงอ้างอิงรูปภาพของภาษาต้นฉบับ ซึ่งทำให้มีการแสดงข้อความ ALT ที่ไม่ถูกต้องในภาษารอง
วิธีแก้ปัญหาชั่วคราว
โปรดตรวจสอบให้แน่ใจว่าคุณได้สำรองข้อมูลเว็บไซต์ของคุณอย่างครบถ้วนก่อนดำเนินการต่อ
- เปิดไฟล์ functions.php ของธีมของคุณ
- เพิ่มข้อมูลโค้ดต่อไปนี้:
// WPML: Find translatable IDs in Elementor Widgets add_filter( 'elementor/frontend/before_render', 'wpml_compsupp_find_translatable_post_ids_in_settings' ); function wpml_compsupp_find_translatable_post_ids_in_settings( $element ) { $widget_name = $element->get_name(); $settings = $element->get_settings(); // Recursively translate post IDs in settings array $translated_settings = wpml_compsupp_find_translatable_post_ids_in_array( $settings, $widget_name ); $element->set_settings( $translated_settings ); } function wpml_compsupp_find_translatable_post_ids_in_array( $settings, $widget_name, $path = [] ) { $apply_translations = true; // if set to false, translated IDs are not applied to the content foreach ( $settings as $key => &$value ) { // Translate IDs and handle nested settings $currentPath = array_merge($path, [$key]); if ( is_array( $value ) || is_object( $value ) ) { // If the value is an array or object, run the function recursively $value = wpml_compsupp_find_translatable_post_ids_in_array((array)$value, $widget_name, $currentPath); } elseif ( is_numeric( $value ) && $value != 0 ) { // Translate post ID if it is numeric and a valid post type exists $post_type = get_post_type( $value ); $post_status = get_post_status( $value ); if ( $post_type && $post_status == 'publish' ) { $translated_value = apply_filters( 'wpml_object_id', $value, $post_type, true ); if ($apply_translations === true ) { $value = $translated_value; } } } } return $settings; }