[Resolved] ACF and WPML not working together for repeater_fields?
This thread is resolved. Here is a description of the problem and solution.
Problem: The client is experiencing an issue where the sidebar content on translated pages always appears in English, despite using the WP Translation Editor and setting the ACF repeater field to 'Different fields across languages'. The client tried various code modifications suggested on forums, but none resolved the issue. Solution: We recommend checking the active language and fetching the correct post ID based on that language. Here is an example of how you can modify your code:
This solution is specific and may only work for a limited number of translations. If this approach does not suit your needs or if you are using a different setup, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins.
If the problem persists, please open a new support ticket at WPML support forum for further assistance.
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.
Background of the issue:
- I have a number of ACF fields, among which a repeater field (sidebar_item).
- The repeater field is set to 'Different fields across languages'.
- I am using the WP Translation Editor (not WPML Advanced Translation Editor) to manage external translations.
- The repeater field and content appear fine in WP Admin on the original (English) and translation pages (RU and UZ).
- The theme includes them in the sidebar on pages under 'Services' (or similar pages in RU and UZ), but they always appear in English.
I have spent quite some time researching what could go wrong between WPML and ACF (ACFML 2.1.5), but cannot find a solution.
I have tried changing ACF to indicate that the sidebar item (sidebar_item) is the same across all languages. No difference.
I have tried changing ACF to indicate that the sidebar item (sidebar_item) to expert mode. No difference.
I have tried a few variations of the_sub_field that are recommended on posts on Stackoverflow, such as with 'option' as a second parameter, with false or true as a second parameter, with 'iventure-uz' (the theme name) as a second parameter, but none of these help.
Symptoms:
The two sidebar contents on translated pages always appears in English instead of the respective language. hidden link hidden link hidden link
Questions:
Why does the sidebar content always appear in English on translated pages?
How can I ensure the sidebar content is displayed in the correct language on the front end?
This ticket has been inactive for quite a while. I didn't get a reply from you. So, I've transformed this chat into a support ticket because you may still need our help. If you do, please reply to this ticket, and one of our supporters will continue helping you.
Is htis the sidebar with the problem?
Please see the attached screenshot.
If you need further help with this, please share the access details to your site with me. I'm enabling a private message for the following reply. Privacy and Security Policy
We have strict policies regarding privacy and access to your information. Please see: https://wpml.org/purchase/support-policy/privacy-and-security-when-providing-debug-information-for-support/ **IMPORTANT**
- - Please backup the site files and database before providing us access. --
-- If you have a staging site where the problem can be reproduced, it is better to share access to the staging site.--
For points 1 and 2, Please see the attached screenshot sidebar-box-group.jpg.
3. Repeater fields are added with the ACF Pro plugin. However, you are not using the Pro plugin. Please see the attached screenshot no-acf-pro.jpg. You have installed the Advanced Custom Fields: Repeater Field plugin, a very old plugin by the original author of ACF. This plugin is not supported anymore. You can see a reference for this here.
hidden link
The Repeater Field add-on is available within ACF PRO. It is no longer available as a plugin.
To correct this issue, follow these steps.
1. Install the ACF Pro plugin.
2. Correct the Sidebar box field group to include the sub-fields.
3. Assign it to the right page: hidden link">Accounting
4. Update the original page and its translations.
Thanks - I did not see your response previously, but have now turned on email updates for responses.
1) The sidebar_item automatically has a sub-field "box_cotent" which you can see on the Services page and its translations to maintain the value.
Of course, I can add an explicit sub-field box_content, but that seems to already be working.
2) The field group is maintained in the parent page "Services" (post ID 28), but displayed in all of the subpages: Accounting, Specialty Services, Entering the US Market -
<?php if( have_rows('sidebar_item',28) ): while ( have_rows('sidebar_item',28) ) : the_row(); ?>
It does this correctly in English (hidden link, hidden link, hidden link)
3) Unfortunately, I am just the support person for this website - I will have to check with my client if they are willing to pay $100/year for repeater fields.
I may have to rewrite that code so that it explicitly uses sidebar_item_1 and sidebar_item_2 - not as elegant a solution, but it's free (other than my time).
Recommended steps:
1) I will check if the client accepts ACF Pro
2) Sidebar box already works in English, so I don't think that this is required
3) have_rows for ('sidebar_item', 28) gives the 2 sidebar_items for Services.
4) The original page is working fine and the translations are already present... they simply don't show.
I suspect that this is due to the old ACF Repeater Field plug-in not working correctly with WMPL.
You have a custom solution that we can't support at this point. In general, supporting custom code is out of the scope of our support forum. However, we try our best to help with custom code when a client presents it and explains what they expect to get. However, in your case, the old Advanced Custom Fields: Repeater Field plugin is not even supported by the authors of ACF, so naturally, it is also not supported by WPML. I can only consult our second-tier supporters about your code if things do not work when you use the ACF Pro plug, the plugin that is officially compatible with WPML. If you want, I can create a sandbox site for you to test things with ACF + Pro + WPML.
So an inelegant solution was to check which language was active and get the correct post ID:
elseif( get_language_shortcode() === 'ru' && have_rows('sidebar_item',9345) ): while ( have_rows('sidebar_item',9345) ) : the_row(); ?>
elseif( get_language_shortcode() === 'uz' && have_rows('sidebar_item',9344) ): while ( have_rows('sidebar_item',9344) ) : the_row(); ?>
Of course, this only works for a small number of non-changing language translations, but it suits our needs for the moment with no cost.
Manage Cookie Consent
We use cookies to optimize our website and services. Your consent allows us to process data such as browsing behavior. Not consenting may affect some features.
Functional
Always active
Required for our website to operate and communicate correctly.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
We use these to analyze the statistics of our site. Collected information is completely anonymous.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
These cookies track your browsing to provide ads relevant to you.