WPML
状态
已由作者解决
相关插件/主题
The Plus Addons for Elementor
主题标签
Compatibility, Elementor Custom Widgets

问题概述

使用 The Plus Addons for Elementor Pro 时,Tabs 小工具内的内容未被翻译。

临时解决方法

在继续操作之前,请确保您的站点拥有完整站点备份


  • 打开主题的functions.php文件。
    add_filter('elementor/frontend/before_render', 'wpml_compsupp7837_filter_loop_grid_widget');
    
    function wpml_compsupp7837_filter_loop_grid_widget($element) {
        if ('tp-tabs-tours' !== $element->get_name()) {
            return $element;
        }
    
        $settings = $element->get_settings();
    
        if (!isset($settings['tabs']) || !is_array($settings['tabs'])) {
            return $element;
        }
    
        $tabs = $settings['tabs'];
    
        foreach ($tabs as $key => $value) {
            if (empty($value['content_template']) || !is_numeric($value['content_template'])) {
                continue;
            }
            // Use apply_filters to adjust template_id for WPML
            $id = apply_filters('wpml_object_id', $value['content_template'], get_post_type($value['content_template']), true);
            if (!is_numeric($id)) {
                continue;
            }
            $tabs[$key]['content_template'] = $id;
        }
    
    
        $settings['tabs'] = $tabs;
        $element->set_settings('tabs', $settings['tabs']);
    }
            

所有已知问题 →