Skip Navigation

Resolved

Resolved in: 1.9.0

Overview of the issue

When you create an ACF Options Page and specify the post_id for this page in a way similar to this:

acf_add_options_page([
   'page_title' => __('Portfolio options', 'my-theme'),
   'post_id' => 'portfolio',
   'parent_slug' => 'edit.php?post_type=my_portfolio',
]);

You will not be able to translate this options page with WPML. The translation will always be copied to other languages (will overwrite the default language).

Workaround

You should not specify post_id. Your code to register ACF Options Page should look like this:

acf_add_options_page([
   'page_title' => __('Portfolio options', 'my-theme'),
   'parent_slug' => 'edit.php?post_type=my_portfolio',
]);

Please keep in mind if you are updating code for the already existing options page with some entries in the fields you will have to provide entries again (updating the code will deregister your options page and register it again).

11 Responses to “Advanced Custom Fields (ACF) - Can't translate options page when specifying a custom post_id”

  1. Hello,

    unfortunately it took me a few hours until I stumbled across this info more or less by accident.

    I would appreciate it very much if links to this info would be in the relevant places in the documentation and not somewhere at the bottom of the page. Also, it would be great if the plugin would show a warning when you create an options page with a custom post ID ( and WPML is active ).

    Looking forward to seeing the improvement! Thanks a lot!

    Best regards,
    Peter

    • Hello Peter,
      Thank you very much for your feedback, I totally see your point. I’ll transfer this information to our team and see how we can improve our documentation and prevent these situations.
      Regards

    • Hi Peter,

      Thanks again for your feedback!

      I just wanted to let you know that all the information related to ACF’s compatibility with WPML is available on ACF’s compatibility page:
      https://wpml.org/plugin/advanced-custom-fields/

      This includes links to the documentation and all the open errata.

      This issue is scheduled to be resolved in ACFML’s next major release.

      Hope this helps 🙂

      • Hello,

        to be frank and honest: The reference to https://wpml.org/plugin/advanced-custom-fields/ does not help.

        You search for hours in the support forum and work through the documentation (https://wpml.org/documentation/related-projects/translate-sites-built-with-acf/#translate-option-pages) and it just doesn’t work.

        Only much later and by chance you discover the “Known Issues” at the bottom of the page.
        It’s nice that elsewhere and on another page the existing problems are pointed out, but in my opinion these hints should be additionally available at the relevant places.

        A short sentence: “If the translation of the fields on the options page does not seem to work, please check if a custom post_id has been set for the options page. The translation only works with the default ID at the moment.” would be enough.

        But maybe I missed something (for hours)?!

        Regards

        • Hi Peter,

          Your feedback is highly appreciated!

          We will make sure that such information is placed where it could be easily found.

    • Hi Peter,

      This issue should be fixed in ACFML 1.9.0. Unfortunately, I can’t provide a solid time estimate on when it will be ready as the development work is still in its early stages.

  2. How can I avoid translations of options pages. I have all installed and the options page uses a custom slug but the fields are still translated. I don’t want WPML doing anything to m technical and site wide settings.

    • Hey Max,
      You can always set your Custom fields as “Don’t translate” in WPML > Settings Custom fields. However, if the workaround here presented does not solve your issue or if you want are intending to achieve something different, please open a ticket in our support forum so we can help you better:
      https://wpml.org/forums/forum/english-support/

  3. Workarround:

    Setup a `post_id` value based on the current language. A bit dirty but does the job.

    Something like :

    if ( !defined('LANGUAGE_CODE_SUFIX') ) {
    $my_current_lang = apply_filters( 'wpml_current_language', NULL );
    if($my_current_lang=='en') $my_current_lang = ''; // do not add sufix for main language
    define( 'LANGUAGE_CODE_SUFIX', $my_current_lang );
    }

    acf_add_options_sub_page(array(
    'page_title' => __('My option page'),
    'menu_title' => __('My option page'),
    'post_id' => 'my-option-page'.LANGUAGE_CODE_SUFIX
    ));

    Then use the prefix also to get your fields value in front.