탐색 건너뛰기

Open

Topic Tags: Compatibility

Overview of the issue

When using Elementor Pro’s Loop Grid with alternate templates, non-dynamic content translated within the loop template does not appear in the correct language on the frontend. This issue occurs because the alternate template IDs are not translated.

Workaround

Please, make sure of having a full backup of your site before proceeding.

  • Open your theme’s functions.php file.
  • Add the following code:
    // 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']);
    }
    

답장을 남겨주세요

주제를 유지하고 다른 사람을 존중하십시오. 이 게시물과 관련 없는 문제에 대한 도움이 필요한 경우 지원 포럼을 사용하여 채팅을 시작하거나 티켓을 제출하십시오.

다음 태그를 사용할 수 있습니다.
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>