탐색 건너뛰기

Open

Topic Tags: Compatibility

Overview of the issue

When using the Premium Addons for Elementor plugin, the Blog widget does not display posts in secondary languages if you include or exclude post categories.

Workaround

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

  • Open your theme’s functions.php file.
  • Add the following snippet:
    // WPML Workaround for compsupp-7625
    add_action( 'elementor/frontend/widget/before_render', 'wpml_compsupp7625_modify_premium_blog_tax_filter', 10, 1 );
    
    function wpml_compsupp7625_modify_premium_blog_tax_filter( $widget ) {
        // Check if this is the Premium Blog widget
        if ( 'premium-addon-blog' !== $widget->get_name() ) {
            return;
        }
    
        $settings = $widget->get_settings();
    
        // Check if WPML is active
        if ( class_exists('Sitepress') ) {
            // Get the active languages from WPML
            $languages = apply_filters('wpml_active_languages', NULL, array('skip_missing' => 0));
    
            $post_type = $settings['post_type_filter'];
            $filter_types = array('category', 'tag', 'author');
    
            foreach ($filter_types as $filter_type) {
                $filter = ($filter_type === 'tag') ? 'post_tag' : $filter_type;
                $setting_key = "tax_{$filter}_{$post_type}_filter";
    
                if (isset($settings[$setting_key]) && is_array($settings[$setting_key])) {
                    $modified_filters = $settings[$setting_key];
    
                    foreach ($settings[$setting_key] as $filter_term_slug) {
                        $term_object = get_term_by('slug', $filter_term_slug, $filter);
                        if ($term_object) {
                            $filter_term_id = $term_object->term_id;
    
                            foreach ($languages as $language) {
                                $translated_term_id = apply_filters('wpml_object_id', $filter_term_id, $filter, false, $language['language_code']);
    
                                if ($translated_term_id) {
                                    $translated_term_object = get_term_by('id', $translated_term_id, $filter);
                                    if ($translated_term_object && !in_array($translated_term_object->slug, $modified_filters)) {
                                        $modified_filters[] = $translated_term_object->slug;
                                    }
                                }
                            }
                        }
                    }
    
                    $settings[$setting_key] = $modified_filters;
                }
            }
    
            $widget->set_settings($settings);
        }
    }
    

답장을 남겨주세요

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

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