Open
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); } }