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
- 8:00 – 13:00 9:00 – 13:00 9:00 – 13:00 8:00 – 12:00 8:00 – 12:00 -
- 14:00 – 17:00 14:00 – 18:00 14:00 – 18:00 13:00 – 17:00 13:00 – 17:00 -

Supporter timezone: Europe/Zagreb (GMT+01:00)

This topic contains 6 replies, has 2 voices.

Last updated by Bruno Kos 10 months ago.

Assisted by: Bruno Kos.

Author Posts
February 1, 2024 at 7:00 am #15252952

森岡 誠

When updating the terms of posts in the default language by WP ALL IMPORT, these changes of the terms are not synchronized to posts in the other languages.

Are there any bug to fix?

I would like to know how to sync the terms to posts in other languages when updating the terms in the default language by WP ALL IMPORT.

--------------------------

For your information, it is succeeded to sync them by saving a post in the default language on the admin in case of not using WP ALL IMPORT.

But, after using WP ALL IMPORT, the synchronization doesn't work well.
The terms before updating remain in posts in the other languages.

For example:

0. Terms before updating
Default lang: term-a term-b
En: term-a-en, term-b-en

1. Terms after updating by WP ALL IMPORT
Default lang: term-c, term-d
En: term-a-en, term-b-en

2. Terms after saving a post on the admin
Default lang: term-c, term-d
En: term-a-en, term-b-en, term-c-en, term-d-en

February 1, 2024 at 7:06 am #15252986

森岡 誠

Tentatively, I use the hook as follows.

function wpml_sync_terms_on_updating_original_post_by_wpallimport($original_post_id, $xml_node, $is_update){
  $import_id = wp_all_import_get_import_id();
  if ( $import_id !== '33' ) return;
  if ( ! $is_update ) return;

  $langs = array('en', 'zh', 'ko', 'vi');

  foreach ( $langs as $lang ) {
    $translated_post_id = apply_filters('wpml_object_id', $original_post_id, 'sharehouse', false, $lang);

    if ( (bool) $translated_post_id === true ) {
      $taxonomy_slugs = get_post_taxonomies($original_post_id);
      foreach ( $taxonomy_slugs as $tax ) {
        $terms_on_original = wp_get_object_terms( $original_post_id, $tax );
        if ( is_wp_error($terms_on_original) ) continue;

        $translated_term_ids = array();
        foreach ( $terms_on_original as $term ) {
          $translated_term_id = apply_filters('wpml_object_id', $term->term_id, $tax, false, $lang);
          if ( (bool) $translated_term_id === true ) {
            $translated_term_ids[] = $translated_term_id;
          }
        }

        wp_set_object_terms($translated_post_id, $translated_term_ids, $tax, false);
      }
    }
  }
}
add_action( 'pmxi_saved_post', 'wpml_sync_terms_on_updating_original_post_by_wpallimport', 10, 3 );

This code seems to work well at the moment.

February 1, 2024 at 11:54 am #15254714

Bruno Kos
Supporter

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

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

Hi,

Thank you for contacting WPML support!

If you run an import but without your code and after the import is done, you try this:

- WPML - > Support -> Troubleshooting:
– Synchronize posts taxonomies (for your product type)

Does it fix taxonomies in the same way as your code?

Regards,
Bruno Kos

February 1, 2024 at 12:40 pm #15254946

森岡 誠

Thank you for your advice.

But your advice doesn't solve my problem.

Why aren't the terms synchronized to posts in other languages when updating the terms in the default language by WP ALL IMPORT?

I feel that this situation is the bug of plugin to fix because it is strange that there is a difference in the synchronization process between updating with WP ALL IMPORT and updating on the admin.

For your information, I know the troubleshooting function you mentioned and have already tried it.
But it didn't work well. It led that the terms before updating remain in posts in the other languages.

February 1, 2024 at 2:17 pm #15255307

Bruno Kos
Supporter

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

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

When you do the update of these new terms, do translations of these terms already exist in another language?

Because check this:
https://wpml.org/documentation/related-projects/wpml-all-import-plugin-website-import-with-wpml/importing-multiple-languages-with-wp-all-import-and-wpml/#option-2-import-the-multilingual-terms-using-wp-all-import

Specifically step 3 - so an import in secondary language is needed and then https://wpml.org/documentation/related-projects/wpml-all-import-plugin-website-import-with-wpml/importing-multiple-languages-with-wp-all-import-and-wpml/#import-the-secondary-language-file

February 2, 2024 at 12:02 am #15257241

森岡 誠

Of course I know...
The translation for the terms exist.

February 2, 2024 at 9:55 am #15258426

Bruno Kos
Supporter

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

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

Can I ask you to do a simple import here?
hidden link

So first import of original language and then the translation and let us know what we need to do then - do the first import again, but this new import will include new taxonomies?

These should be there before the import though.

It would also help if you record a video using tool such as hidden link to show us these final steps.

The topic ‘[Feature Request] Not synchronized the terms of post when using WP ALL IMPORT’ is closed to new replies.