Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
You are using the Premium Addons for Elementor, specifically the blog widget with a category filter, and encountering issues where no articles are found in the translated blog widget or the category bar disappears when modifying the first label text.
Solution:
We identified this as a compatibility issue with Premium Addons for Elementor. Initially, we attempted to reproduce and debug the issue on a sandbox site. After confirming the problem persists, we provided a code snippet to be added to the functions.php file of your theme. This code adjusts the category filters based on the active languages in WPML, ensuring the correct translation and display of categories in different languages. Here is the code you need to implement:

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

Please ensure to back up your site fully before implementing this code. If this solution does not resolve your issue or seems irrelevant due to updates or different configurations, we recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If issues persist, please open a new support ticket at WPML support forum.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Tagged: 

This topic contains 14 replies, has 2 voices.

Last updated by Bigul 8 months ago.

Assisted by: Bigul.

Author Posts
September 30, 2024 at 10:53 pm #16237760

karimG-6

Background of the issue:
I am using Premium Addons for Elementor (blog widget) and trying to have a translated blog widget with a category filter. The issue can be seen on this page: hidden link
The categories and their translations are well mapped.

Symptoms:
The current query has no posts. Please make sure you have published items matching your query.

Questions:
Why are no articles found in the translated blog widget?

September 30, 2024 at 11:13 pm #16237824

karimG-6

Sometimes all the the articles appear but the category filter bar disappear

Capture d'écran 2024-10-01 001052.png
October 1, 2024 at 11:24 am #16239959

Bigul
WPML Supporter since 01/2013

Languages: English (English )

Timezone: Europe/Vienna (GMT+02:00)

Hello,

Welcome to the WPML support forum. I will do my best to help you to resolve the issue.

We hope you have translated all the posts and pages into a secondary language. A couple of requests for tracking this.

1) Please let us know the exact steps to reproduce the issue on your site

2) Please fill the private details fields after a full site backup{mandatory}. I would like to access the admin area of your site for further checking. Refer to the following links for more details about our private information-sharing policies.

https://wpml.org/purchase/support-policy/privacy-and-security-when-providing-debug-information-for-support/

hidden link

--
Thanks!

Bigul

October 1, 2024 at 3:59 pm #16241828

Bigul
WPML Supporter since 01/2013

Languages: English (English )

Timezone: Europe/Vienna (GMT+02:00)

Hello,

Thank you for the details and login information. Please upgrade to the latest version of Elementor, Elementor Pro, and Premium Addons for Elementor after a full site backup. Then make sure the issue exists or not.

If the problem remains, please allow me to create a test page on the site to check it.

--
Thanks!

Bigul

October 1, 2024 at 4:20 pm #16242059

karimG-6

Done, but nothing changed

October 2, 2024 at 12:41 pm #16245545

Bigul
WPML Supporter since 01/2013

Languages: English (English )

Timezone: Europe/Vienna (GMT+02:00)

Hello,

Thank you for the updates. Please allow me to make a copy of your site using the Duplicator plugin (https://wordpress.org/plugins/duplicator/) for debugging the issue on my local server. So we can troubleshoot the bug without affecting your live site.

--
Thanks!

Bigul

October 2, 2024 at 12:43 pm #16245598

karimG-6

My site is not yet on production, so you can proceed. Thank you

October 2, 2024 at 4:16 pm #16246677

Bigul
WPML Supporter since 01/2013

Languages: English (English )

Timezone: Europe/Vienna (GMT+02:00)

Hello,

Thank you for the updates. I am testing it on your site now and get back to you as soon as possible. Please wait.

hidden link (a private page)

--
Thanks!

Bigul

October 2, 2024 at 4:19 pm #16246708

karimG-6

Thank you in advance, it's very urgent !

October 4, 2024 at 1:30 pm #16254433

karimG-6

Hi,

PA support said that it's a WPML issue. If it's not resolved today I have to change PA, abandon WPML, and change more then 20 pages, otherwise I will lose my job.

October 4, 2024 at 2:03 pm #16254680

Bigul
WPML Supporter since 01/2013

Languages: English (English )

Timezone: Europe/Vienna (GMT+02:00)

Hello,

Thank you for the feedback. This looks like a compatibility issue with Premium Addons for Elementor. The possible workarounds are not helping in this case. So sorry about your tight situation.

Therefore I have created a test site in our Sandbox Server for further debugging of this bug. Reproducing the issues in a fresh/minimal installation will help us a lot in debugging and also we can escalate the ticket directly to our compatibility team to find a fix.

Please try the following steps and make sure the bug exists or is not on the sandbox site.

1) Click this URL to visit the Sandbox site backend - hidden link
2) Configure WPML like your live site and activate WPML add-ons
3) Install and activate Premium Addons for Elementor
5) Create a couple of posts in the original language and translate it
6) Create a page with filters and translate it

--
Thanks!

Bigul

October 4, 2024 at 2:09 pm #16254685

Bigul
WPML Supporter since 01/2013

Languages: English (English )

Timezone: Europe/Vienna (GMT+02:00)

Hello,

Thank you for the feedback. This looks like a compatibility issue with Premium Addons for Elementor. The possible workarounds are not helping in this case. So sorry about your tight situation.

Therefore I have created a test site in our Sandbox Server for further debugging of this bug. Reproducing the issues in a fresh/minimal installation will help us a lot in debugging and also we can escalate the ticket directly to our compatibility team to find a fix.

Please try the following steps and make sure the bug exists or is not on the sandbox site.

1) Click this URL to visit the Sandbox site backend - hidden link
2) Configure WPML like your live site and activate WPML add-ons
3) Install and activate Premium Addons for Elementor
5) Create a couple of posts in the original language and translate it
6) Create a page with filters and translate it

--
Thanks!

Bigul

October 4, 2024 at 4:49 pm #16255456

karimG-6

The problem is still there even on the sandbox

October 4, 2024 at 5:46 pm #16255546

Bigul
WPML Supporter since 01/2013

Languages: English (English )

Timezone: Europe/Vienna (GMT+02:00)

Hello,

Thank you for the quick response and for replicating the bug in the sandbox site. The ticket is escalated to our compatibility team for further debugging. We will get back to you as soon as possible. Please wait.

--
Thanks!

Bigul

October 14, 2024 at 3:48 pm #16287102

Bigul
WPML Supporter since 01/2013

Languages: English (English )

Timezone: Europe/Vienna (GMT+02:00)

Hello,

Sorry for the late response. We were trying for an easy workaround to fix this bug. We are getting the expected results in the sandbox site after adding the following code in the functions.php file of the theme - hidden link

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

Please try it on your site after a full site backup {mandatory} and let us know your feedback.

--
Thanks!

Bigul