I’ve been using the Advanced Custom Fields plugin for WordPress for nearly five years, and it’s implemented in every project I’ve created or worked on since I began using it. At work, our WordPress Themes depend on Theme Options, which are set using custom fields created by the plugin.

In order to make the technique work well for multilingual sites at work, we’ve worked hard on many different configuration ideas, before finally reaching the one which works logically and in a robust way.

  • Register an ACF options page, using the ID options.
  • Create an ACF field group “Theme options (for clone)” containing the options fields, but leave the status of the group as inactive.
  • Create a second ACF field group “Theme options” with an active status, and define that it will appear on the ACF options page you’ve registered.
  • Add a “group” field. The label should be (e.g.) German fields and the field name (or “key”), which is used for the database, should be “de”. This field must be a clone field, and reference the inactive field group “Theme options (for clone)”. Make sure that you activate the option to add field name prefixes, e.g. de_%field_name%.
  • Add another “group“ field for the next language. e.g. English options with the key “en”. Again, activate field name prefixes, e.g. en_%field_name%

Add a few values to the fields you’ve created, then do a var_dump of get_fields('options') in PHP in the frontend of the website. You’ll see that you have an array containing two subarrays, like the following simple example.

Array
(
    [en] => Array
        (
            [header] => Array
                (
                    [logo] => "logo_en.png",
                    [logo_text] => "My logo text",
                    [external_site_link] => "https://www.example.com/"
                )
        )

    [de] => Array
        (
            [header] => Array
                (
                    [logo] => "logo_de.png",
                    [logo_text] => "Mein Logo-Text",
                    [external_site_link] => "https://www.example.de/"
                )
        )
)

Leave a Reply

Your email address will not be published. Required fields are marked *

For security, use of Google’s reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

This site uses Akismet to reduce spam. Learn how your comment data is processed.