Skip Navigation

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.

Sun Mon Tue Wed Thu Fri Sat
- 12:00 – 14:00 12:00 – 14:00 12:00 – 14:00 12:00 – 14:00 12:00 – 14:00 -
- 17:00 – 21:00 17:00 – 21:00 17:00 – 21:00 17:00 – 21:00 17:00 – 21:00 -

Supporter timezone: Europe/Vienna (GMT+02:00)

This topic contains 5 replies, has 1 voice.

Last updated by Bigul 3 days, 9 hours ago.

Assisted by: Bigul.

Author Posts
May 7, 2025 at 9:02 am #17005169

Ralph Klerk

Background of the issue:
I am trying to import products (property-listings) to our site using WP All Import and WPML All Import. The main language of the site is Dutch, and the secondary language is French, which is hidden on the frontend. All products should be imported in French and are translated to Dutch if needed. This process works fine when running the import from the backend. However, when using the WP All Import cron task, all products are imported/updated to Dutch. I attempted to force the language before the import with $sitepress->switch_lang('fr') or do_action('wpml_switch_language', 'fr'), but it had no effect.

Symptoms:
When running the import using the WP All Import cron task, all products get imported/updated to Dutch instead of French.

Questions:
Could the issue be related to the fact that French is hidden?
Why does forcing the language before the import have no effect?

May 8, 2025 at 8:53 am #17010318

Bruno Kos
WPML Supporter since 12/2018

Languages: English (English ) German (Deutsch ) French (Français )

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

Hi,

When WP All Import is triggered via cron, I believe that WPML defaults to the site’s main language (Dutch) unless we explicitly set it.

What if you try this?

add_action('pmxi_before_xml_import', function($import_id) {
    if (defined('DOING_CRON') && DOING_CRON) {
        global $sitepress;
        $sitepress->switch_lang('fr');
    }
}, 10, 1);

This is based on hidden link

This should ensure that whenever the import runs via cron, WPML is switched to French before any data is processed, so all products are created or updated in the correct language.

Can you try this?

May 8, 2025 at 11:55 am #17011417

Ralph Klerk

Hi Bruno, unfortunately this doesn't work using the wp all import cron. I've logged the language using:

$my_current_lang = apply_filters( 'wpml_current_language', NULL );
echo $my_current_lang;

After your code and it returns the main language of the site (nl).

To be clear: I've checked your code when we are logged in in the back-end and run the cron in the same browser/window. Then it does return the desired language (fr).

So it seems to be related to the login state and the hidden language not being available for the (WP All import) cron.

Any way to force this somehow?

May 9, 2025 at 2:48 pm #17017142

Bigul
WPML Supporter since 01/2013

Languages: English (English )

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

Hello,

Thank you for the updates. Please note that with WP All Import Pro and the WPML All Import Glue plugin, the recommended workflow is to first import products in the default language and then import the translated versions separately. It is not possible to import products directly into a secondary language. Therefore, it is an expected result now.

So I shared the details with our second-tier team for further checking. We will get back to you as early as possible. Please wait.

--
Thanks!

Bigul

May 12, 2025 at 8:44 am #17021519

Ralph Klerk

Hi Bigul, I think your remark regarding

"It is not possible to import products directly into a secondary language. Therefore, it is an expected result now. "

isn't right, because it works perfectly on some of our others sites and the only difference is that we have our secondary language hidden on this one. Hopefully your second-tier team has some hints/a workaround.

May 13, 2025 at 6:47 am #17025290

Bigul
WPML Supporter since 01/2013

Languages: English (English )

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

Hello,

Thank you for the updates. The ticket has been escalated to our developers as a feature request. We will get back to you as soon as we have feedback. Thank you for your patience, and please stay tuned.

--
Thanks!

Bigul