Skip Navigation

Open

Reported for: Advanced Custom Fields Multilingual 1.10.4

Overview of the issue

If you are translating your WordPress native custom fields or using an extension such as Advanced Custom Fields (ACF), you may need to modify your translation preferences as your project evolves. However, as we state in our documentation, you will need to update your content to have those custom fields available for translation in the Advanced Translation Editor:

If you make a change in the translation preferences for your ACF fields, you should make a small change to the post in the original language using the fields and Save your changes. This has to be done in order for you to be able to update the translation.

Although it is expected, we totally understand that it is not desirable, particularly if you have a large site and your translations are in an advanced state.

Workaround

Please, be sure to make a full backup of your site before proceeding.

Note: Keep in mind that if you are using our Translate Everything feature, those custom fields will be automatically translated.

  1. Add the following snippet in your functions.php file keeping in mind to modify these two values for yours.
    • Post type name: post
    • Custom field name: simple_field
      add_action('wp', function(){
          $config = [
              'post_type' => 'post', //Post type slug
              'meta_key_name' => 'simple_field' //Custom field key
          ];
         
          if (!isset($_GET['wpml_sync'])) {
              return;
          }
         
          set_time_limit(0);
          do_action('wpml_switch_language', apply_filters( 'wpml_default_language', null ));
          $all_posts = get_posts([
              'post_type' => $config['post_type'],
              'posts_per_page' => -1,
              'suppress_filters' => false
          ]);
         
          if (empty($all_posts)) {
              return;
          }
         
          foreach ($all_posts as $post) {
              do_action( 'wpml_sync_custom_field', $post->ID, $config['meta_key_name'] );
          }
         
          wp_die('Done!');
      });
      
  2. Visit your website and add this to your URL: /?wpml_sync (e.g.
    https://example.com/?wpml_sync)
  3. Remove the code from your file.

3 Responses to “Changing translation preferences for custom fields does not make them appear automatically in the Advanced Translation Editor”

  1. This doesn’t seem to be working for me. When I update the ACF value in WordPress, the translation UI appears in the WPML Advanced editor, but when I set the ACF value back to the original (which I require), the translation UI disappears from the advanced editor again.

    Not sure if I’m doing this right: My meta_key_name is free_type_details_form_id which is a text value “form_id” within a group layout named “free_type_details”. I’ve tried free_type_details_form_id, field-free_type_details_form_id, the “field_xxxxxxxx” key name, not sure which to use. My post type seems correct since I have entries in $all_posts and I reach the end.

    • Hey there,
      Have you tried adding just a blank space, in that way you don’t need to set your ACF value back to the original. Anyway, don’t hesitate to open a ticket in our support forum if this does not help or if it is a different scenario.
      Regards

Leave a Reply

Please stay on topic and be respectful to others. If you need help with issues not related to this post, use our Support Forum to start a chat or submit a ticket.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>