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.

Tagged: 

This topic contains 1 reply, has 2 voices.

Last updated by Dražen 1 year, 9 months ago.

Assisted by: Dražen.

Author Posts
September 5, 2023 at 7:24 pm #14347173

mandaS

Tell us what you are trying to do?
I'm using the WPML extension for WP All Import PRO, I need to activate an option to delete all categories not found in the current xml import. When doing this the plugin deletes all the other WPML translations also, is there a way to fix this? And delete only what's missing from the current language?

Is there any documentation that you are following?
This page already explains how to do this with posts and products: https://wpml.org/forums/topic/issue-with-deleting-registers-not-found-when-importing-data/ but I'm not getting it fixed for categories.

Is there a similar example that we can see?
I'm using this code to delete only the products in the current language:

add_filter( 'wp_all_import_is_post_to_delete', function( $to_delete, $post_id, $wpallimport_record ) {
$post_language_details = apply_filters( 'wpml_post_language_details', NULL, $post_id );
$post_language = $post_language_details['language_code'];
$import_process_language = $wpallimport_record->options['wpml_addon']['lng'];

if ( $post_language != $import_process_language ) {
$to_delete = false;
}

return $to_delete;
}, 10, 3 );

It works great for products and posts! But I'm getting a server error when importing categories. How do I do the same language check for a category? And when the category is missing from the import file > delete it for the current language only and not delete all other translations.

September 7, 2023 at 6:29 am #14356051

Dražen
Supporter

Languages: English (English )

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

Hello,

thanks for contacting us.

First, let me point out that we do not support or debug issues with custom code. What my colleague shared was out of scope and if it causes any issues or doesn't work, you would probably need to hire a contractor for further help.

I would like us to concentrate on only WPML All Import and WPML, without any additional custom code etc.

As for deleting categories while importing, WP All import has such an option in import settings and you can enable it and it should delete it, and work fine with WPML. If not, we should check it further and find out why not.

As I understand it deletes all translations for you, which is expected if you have that option enabled from WPML > Settings. Please make sure it is disabled.

Let me know if that helps.

Regards,
Drazen

Screenshot_2.jpg