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.

This topic contains 1 reply, has 2 voices.

Last updated by Bernat Torras 4 years, 6 months ago.

Assigned support staff: Bernat Torras.

Author Posts
March 14, 2017 at 1:31 am #1229425


I am trying to: sync fields between languages. I have created with Toolset Type plugin the custom post type: consultant and the custom fields "Average Rating" and "Total Ratings". I have selected the field to be copied from original language to english.

The issue is that when the Average Rating is Updated the value does not change in English. So the consultants appear with different ratings in each language. After a little search I found, modified and added in my functions.php the code:

function sync_field_meta( $post_id, $post, $update ) {

    $post_type = get_post_type($post_id);
    // use this if u have muti custom post type
    $posts_type = array('consultant');

    if( ! in_array($post_type, $posts_type)) return;

    $el = apply_filters( 'wpml_object_id', $post_id, 'any', FALSE, 'el' );
    $en = apply_filters( 'wpml_object_id', $post_id, 'any', FALSE, 'en' );

    // your acf key like (field_58136c9dc9963) you can check documention
    $field = get_field('wpcf-average-rating',$post_id);


add_action( 'save_post', 'sync_field_meta', 10, 3 );

but unfortunatelly it does not work. Is there any error in the function or is there any other way so the fields will be totally synced between languages when they are updated?

Thank you,

March 14, 2017 at 1:44 pm #1229984

Bernat Torras

Hi @ioannis,

Thanks for contacting support, I'll do my best to help you with this! 🙂

In fact, if you want to synchronize the value of specific custom post types after saving or updating a post, you could easily do this following these steps:

1- Disable your custom code (just to be sure it doesn't collide with our functionality)

2- Go to WPML>Translation Management>Multilingual Content Setup and scroll down to "Custom Field Translation" section.

3- There you'll see a list of all your custom fields with their translation options. You just need to search for the custom fields that you want to sync and select their 'Copy' option. Once done, save these settings.

After having specified them to 'Copy', the value of these fields will be automatically copied (synchronized) to all post translations after saving or updating it.

Could you try it and tell us if it works for you?