WPML
Trạng thái
Đã giải quyết
Đã giải quyết trong
WPML Multilingual CMS 4.7.4
Plugin/giao diện liên quan
Elementor
Thẻ chủ đề
Compatibility

Tổng quan về lỗi

Khi sử dụng Loop Grid của Elementor Pro với các template thay thế, nội dung không động được dịch bên trong template vòng lặp không hiển thị đúng ngôn ngữ trên frontend. Vấn đề này xảy ra do các ID của template thay thế không được dịch.

Giải pháp tạm thời

Vui lòng đảm bảo có một bản sao lưu đầy đủ cho trang web của bạn trước khi tiếp tục.


  • Mở tệp functions.php của giao diện.

  • Thêm mã sau:
    // WPML Workaround for compsupp-6865
    add_filter('elementor/frontend/before_render', 'wpml_compsupp6865_filter_loop_grid_widget');
    
    function wpml_compsupp6865_filter_loop_grid_widget($element) {
        if ('loop-grid' !== $element->get_name()) {
            return $element;
        }
    
        $settings = $element->get_settings();
    
        if (!isset($settings['alternate_templates']) || !is_array($settings['alternate_templates'])) {
            return $element;
        }
    
        $alternate_settings = $settings['alternate_templates'];
    
        foreach ($alternate_settings as $key => $value) {
            if (empty($value['template_id']) || !is_numeric($value['template_id'])) {
                continue;
            }
    
            // Use apply_filters to adjust template_id for WPML
            $id = apply_filters('wpml_object_id', $value['template_id'], get_post_type($value['template_id']), true);
            if (!is_numeric($id)) {
                continue;
            }
    
            // Update the template_id in alternate_settings
            $alternate_settings[$key]['template_id'] = $id;
        }
    
        // Update the settings with the modified alternate_templates
        $settings['alternate_templates'] = $alternate_settings;
        $element->set_settings('alternate_templates', $settings['alternate_templates']);
    }

Tất cả các lỗi đã ghi nhận →