Open
Reported for: WPML Multilingual CMS 4.6.0
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.
- 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!'); });
- Visit your website and add this to your URL: /?wpml_sync (e.g.
https://example.com/?wpml_sync) - Remove the code from your file.
+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