Saltar navegación

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 respuestas para “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 🙂

    • 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.

  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.