Advanced Custom Fields for Multilingual
Advanced Custom Fields (ACF) serves as a user interface for managing custom field values on a post or for generating new posts when working with multilingual plugins. ACF seamlessly integrates with your multilingual website without requiring any additional formalities. This article provides a step-by-step guide for setting up a successful multilingual ACF installation.
WPML Integration ACF functions smoothly in conjunction with the WPML plugin. Here are some guidelines and recommendations to ensure your website operates seamlessly:
- Enable Field Group Translation Before creating a field group, be sure to enable the “Field Groups” post type for translation. This can be done through the WPML -> Translation management page. In recent versions of ACF, the option for “Fields” may be hidden. If visible, select “Do nothing” to avoid conflicts and unnecessary loading of fields.
- Translate Field Groups Each language on your site will require its own version of a field group. The most straightforward approach is to create your field group in the default language and then use the ‘Duplicate’ tool to replicate it in the target language. You can modify the field’s label and settings, but it’s crucial to keep the field’s name consistent across all translations. ACF uses the field’s name to store data efficiently.
- Editing a Post When editing a post, only the relevant language-specific field groups will be loaded. To create a translation of the post, you can also utilize the ‘Duplicate’ tool as mentioned above. However, make sure to click the ‘Translate Independently’ button to prevent the translated post’s custom fields from being affected by changes to the original post.
- Prevent Data Loss While editing a post, WPML will display a metabox containing a list of all custom fields and options to ‘Translate’ or ‘Copy’ the data. Understanding when to use these settings is crucial to avoiding data loss.
- The ‘Copy’ setting will duplicate the original post’s value to the translated post upon updating. Please note that this setting does not change to ‘Translate’ automatically after saving. Therefore, if you select ‘Copy,’ ACF will not be able to save a unique value for the translated post.
- The ‘Translate’ setting allows ACF to effectively store custom field data in the post without any changes.