WPML
Status
Open
Reported for
WPML Multilingual CMS 4.6.0
Topic tags
Compatibility, Feature request

Overview of the issue

If you are translating your WordPress native custom fields, you may need to modify your translation preferences as your project evolves. However, you will need to update your content to have those custom fields available for translation in the Advanced Translation Editor.

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.

Note: since Advanced Custom Field Multilingual 2.0, this is not anymore the case for ACF fields as it recalculates the content signature for all posts and forces to re-create new translation jobs.

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.

All known issues →