Hello,
Thanks for the feedback & sorry for the late answer! Issues with multilangual features always take a bit more time to debug.
You’re right, there was an issue with the code example in the documentation in order to exclude a specific Options Post ID from the Multilangual module. The correct code is:
add_filter('acfe/modules/multilang/options', 'my_acfe_multilang_options');
function my_acfe_multilang_options($options_post_id){
foreach($options_post_id as $k => $post_id){
// Exclude "my-options" Post ID
if($post_id === 'my-options'){
unset($options_post_id[$k]);
}
}
return $options_post_id;
}
I updated the code accordingly in the documentation, so thank you for pointing it out. However, I’m not really fan of how this hook works right now (doing a foreach
then an unset()
etc…), it’s too complicated. So I’ll add a more simple hook in the next patch and deprecate this one (it will still work tho).
One another thing that your report point out is that the default options
Post ID cannot be excluded from the multilangual module when using Polylang. This will be fixed in the next patch.
Note that Options Post ID
is not the same thing as Options Pages Slug
. Post ID
being the value identifier in the DB, and Slug
being just the Page URL slug. As explained in the documentation:
post_id
(int|string) The $post_id to save and load values from. Can be set to a numeric post ID (123), or a string (‘user_2’). Read more about the available post_id values. Defaults to ‘options’. Added in v5.2.7.
As the default options
post id cannot be excluded from translation with Polylang right now, you can use a different Post ID for your Options Page (for example: my-options
, or settings
) directly from the Options Page UI. See screenshot: https://i.imgur.com/k2FAKGi.png
If you’re using acf_add_options_page()
PHP code to register your options page manually, the setting is post_id
. See documentation. The default post id being options
in both case.
Be careful if you decide to switch the Post ID of an already existing Options Page with already existing values. You’ll have to set your values again. I would recommend to use custom Post ID for new Options Page only.
If you only use the default options
Post ID for all your ACF Options Pages, then you can simply disable the ACFE Multilangual Module, since you can only exclude Post ID (which can be shared across multiple Options Pages), and not “Options Pages” on their own from the translation anyway.
Hope it helps!
Regards.