Home › Forums › General Issues › Options page + polylang › Reply To: Options page + polylang
So my solution is to register as many options pages as the number of languages we have. Each options page has a unique page_id
:
foreach (['ru', 'en', 'es', 'de'] as $lang) {
acf_add_options_sub_page([
'page_title' => "Page name ${$lang}",
'menu_title' => __("Page name ${$lang}", 'textdomain'),
'menu_slug' => "page-name-${lang}",
'post_id' => $lang,
'parent' => 'parent-slug'
]);
}
Then there’s a need to create a field group and duplicate it as many times as the number of options pages we have registered. Each options page has it’s own ID so fields names can be the same.
Now we can simply do:
the_field('my_field_name', 'en');
or even:
the_field('my_field_name', pll_current_language('slug'));
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.