Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client reported an issue where ACF repeater and flexible content fields were not displaying on translated pages in secondary languages if the ACF Field Group is registered programmatically.

Solution:
We acknowledged the issue and informed the client that our developers are working on a fix for a future update of Advanced Custom Fields Multilingual. Meanwhile, we provided two workarounds:
1. Navigate to WPML > Settings > Custom Field Translation and click on Show system fields. Search for the repeater fields that begin with an underscore (_) and set those fields to copy.
2. Alternatively, use the JSON feature of ACF instead of PHP for defining the fields. More information on this can be found at ACF Local JSON documentation.

Please note that the solution provided might be outdated or not applicable to your case. If the issue persists, we highly recommend checking the related known issues, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If you still need assistance, please open a new support ticket in the WPML support forum.

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.

Tagged: 

This topic contains 9 replies, has 2 voices.

Last updated by Andreas W. 1 year, 3 months ago.

Assisted by: Andreas W..

Author Posts
March 1, 2024 at 2:43 pm #15363487

davidb-80

Hello,

I want to report a bug regarding ACF. It implies that the repeaters and flexible content fields do not display in sites powered with WPML when visiting a translated page in any secondary language. Here are the steps to reproduce it :

1) Create a simple repeater field in functions.php or other using acf_add_local_field_group().

<?php
add_action( 'acf/include_fields', function() {
if ( ! function_exists( 'acf_add_local_field_group' ) ) {
return;
}

acf_add_local_field_group( array(
'key' => 'group_65df8b71d1c1a',
'title' => 'Test Repeater Group',
'fields' => array(
array(
'key' => 'field_65df8b716e6aa',
'label' => 'Test Repeater',
'name' => 'test_repeater',
'aria-label' => '',
'type' => 'repeater',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'wpml_cf_preferences' => 1,
'layout' => 'table',
'pagination' => 0,
'min' => 0,
'max' => 0,
'collapsed' => '',
'button_label' => 'Add',
'rows_per_page' => 20,
'sub_fields' => array(
array(
'key' => 'field_65df8b916e6ab',
'label' => 'Element',
'name' => 'element',
'aria-label' => '',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'wpml_cf_preferences' => 2,
'default_value' => '',
'maxlength' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'parent_repeater' => 'field_65df8b716e6aa',
),
),
),
),
'location' => array(
array(
array(
'param' => 'post_type',
'operator' => '==',
'value' => 'page',
),
),
),
'menu_order' => 0,
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => '',
'active' => true,
'description' => '',
'show_in_rest' => 0,
'acfml_field_group_mode' => 'advanced',
) );
} );
?>

2) Create a page and fill in the repeater with content. Publish and translate the page in a secondary language with WPML.

3) On the page, var_dump() the fields with get_field(). You can try using the field name and then the field key.

You will notice that the fields are returned correctly in the primary language, but not in the secondary language. From my testing, the issue also extends to Flexible Content.

I noticed that, in the wp_postmeta table, there are missing entries for the post in the secondary language. Namely, all the entries that start with a underscore "_" followed by the field name that are involved in the repeater/flexible content created earlier are missing.

As WPML is advertised as fully compatible with ACF, I would hope that you could look into this issue. I hope this provides enough insight regarding the issue. If you need any more details, please let me know and I will provide any additional detail required.

Thank you very much for your time and consideration.

March 2, 2024 at 3:11 pm #15365809

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

Your repeater field needs to include:

'wpml_cf_preferences' => 3

and you should make sure that this argument is part of the same field array.

Guides:
https://wpml.org/documentation/related-projects/translate-sites-built-with-acf/setting-the-translation-preferences-for-acf-fields-created-using-php-code/

https://wpml.org/documentation/related-projects/translate-sites-built-with-acf/recommended-custom-fields-translation-preferences-for-acf-and-wpml/

March 4, 2024 at 3:28 pm #15370671

davidb-80

I have a changed the translation preferences for my repeaters and flexible content from 1 to 3 but I don't notice a change in behavior, and the issue is still present.

My small-scale example looks as such currently. Is there another step I could try?

acf_add_local_field_group( array(
'key' => 'group_65df8b71d1c1a',
'title' => 'Test Repeater Group',
'fields' => array(
array(
'key' => 'field_65df8b716e6aa',
'label' => 'Test Repeater',
'name' => 'test_repeater',
'aria-label' => '',
'type' => 'repeater',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'wpml_cf_preferences' => 3,
'layout' => 'table',
'pagination' => 0,
'min' => 0,
'max' => 0,
'collapsed' => '',
'button_label' => 'Add',
'rows_per_page' => 20,
'sub_fields' => array(
array(
'key' => 'field_65df8b916e6ab',
'label' => 'Element',
'name' => 'element',
'aria-label' => '',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'wpml_cf_preferences' => 2,
'default_value' => '',
'maxlength' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'parent_repeater' => 'field_65df8b716e6aa',
),
),
),
),
'location' => array(
array(
array(
'param' => 'post_type',
'operator' => '==',
'value' => 'page',
),
),
),
'menu_order' => 0,
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => '',
'active' => true,
'description' => '',
'show_in_rest' => 0,
'acfml_field_group_mode' => 'advanced',
) );
} );

March 5, 2024 at 9:13 am #15373207

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Did you try to edit your original field values, save the original content, and then open the translation again?

If this will not solve the issue, I would like to offer a test site, to try to recreate the issue for testing.

One-Click-Login:
hidden link

WPML and ACF PRO are installed already.

You can use the File Manager Plugin to add your custom code and I will have a look into this.

Please make sure to leave me a message on this ticket once you are done with this task.

March 5, 2024 at 3:00 pm #15375179

davidb-80

Alright, it is done. I've created a test post that has my test repeater filled and translated. You will see that doing a var_dump() of the repeater field works as expected in the original language, but in the translated language it only returns the count of items from the repeater.

And as I said earlier, it probably has to do that there are some entries missing in the post_meta of the translated post...

March 5, 2024 at 5:28 pm #15375922

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

This looks like a bug to me, and I will run some further tests.

If I can not find a solution until tomorrow, I will escalate the issue to the second tier support.

March 6, 2024 at 3:04 pm #15380324

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

I was able to debug and locate an error inside ACFML that caused that the Repeater Fields appears not to be available in second language.

Until now I am not able to provide you with a workaround.

The issue has been escalated to our second-tier support for further revision.

Once I receive feedback from our team, I will contact you again.

Best regards
Andreas

March 6, 2024 at 4:28 pm #15380787

davidb-80

I appreciate the update. Looking forward to hear back from your team.

Cheers

March 6, 2024 at 4:45 pm #15380880

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

You are welcome 😉

March 7, 2024 at 2:42 pm #15384940

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

Our developers are already aware of this issue and working on a solution in a coming update of Advanced Custom Fields Multilingual.

As workaround:

Go to WPML > Settings > Custom Field Translation and click "Show system fields" next to the section title.

Now, search for your repeater fields and you will find some fields that begin with an underscore (_).

Make sure to set those fields to "copy". See screenshot.

Another workaround, would be to use the JSON feature of ACF in place of PHP hidden link

Best regards
Andreas

image.png