search ]

How to add ACF Options Pages to Polylang websites

If you need to manage translatable content on pages that ACF can’t target directly (like archive pages), ACF Options Pages are the solution. On a Polylang multilingual site, you need each options page to store separate values per language.

Archive pages are “virtual pages” and don’t exist under Pages in the WordPress dashboard.

This guide shows how to create per-language options pages and retrieve the correct field values based on the current language.

Plugin alternative: The ACF Options For Polylang plugin (10,000+ installs) handles this automatically by storing language-specific values in the database. The manual approach below gives you full control without an extra plugin.

Adding an ACF Options Page to a Polylang Site

To add the same Options Page for each of the languages defined in Polylang, add the following code to the functions.php file:

if (function_exists('acf_add_options_page')) {
    // Main Theme Settings Page
    acf_add_options_page();

    $parent = acf_add_options_page(array(
        'page_title' => 'Archive General Settings',
        'menu_title' => 'Archive Settings',
        'redirect' => 'Archive Settings',
    ));
    
    $languages = array('cn', 'en');
    
    // 
    // Language Specific Options
    // Translatable options specific languages. e.g., social profiles links
    // 
    
    foreach ($languages as $lang) {
        acf_add_options_sub_page(array(
            'page_title' => 'Options (' . strtoupper($lang) . ')',
            'menu_title' => __('Options (' . strtoupper($lang) . ')', 'text-domain'),
            'menu_slug' => "options-${lang}",
            'post_id' => $lang,
            'parent' => $parent['menu_slug']
        ));
    }
}

On line 11, define the language codes for each language in Polylang. You can find these codes under Languages > Languages in the WordPress dashboard.

Tip: Instead of hardcoding languages, you can detect them dynamically using pll_languages_list(). Replace line 11 with: $languages = pll_languages_list(); This way, adding a new language in Polylang automatically creates its options page.

Polylang Language Settings - Code

After adding the code, you will see the language-specific options in the WordPress admin:

Polylang Archive Settings

Next, create a new field group and set its Location to the options page:

Field Location in Options Page

After adding fields, the populated options pages will look like this:

Populated Fields - ACF Options

Fetching Fields of the Options Page Based on the Relevant Language

To retrieve the correct field values for the current language, pass pll_current_language('slug') as the second parameter to any ACF function:

<?php $image = get_field('image', pll_current_language('slug')); ?>

Or, for instance, when calling a Repeater Field:

<?php if (have_rows('my_repeater_field', pll_current_language('slug'))) : ?>
    <?php while (have_rows('my_repeater_field', pll_current_language('slug'))) : the_row(); ?>

Make sure to wrap pll_current_language() calls in a function_exists() check if the code might run on a site without Polylang installed.

FAQs

Can I use ACF Options Pages with Polylang without a plugin?
Yes. By creating separate sub-pages for each language using acf_add_options_sub_page() with the language code as the post_id, you can store and retrieve language-specific values without any additional plugin. Use pll_current_language('slug') as the second parameter in get_field() to fetch the correct values.
How do I avoid hardcoding language codes in the options page code?
Replace the hardcoded language array with pll_languages_list(), which dynamically returns all active language codes from Polylang. This way, when you add or remove a language in Polylang, the options pages update automatically without code changes.
What is the ACF Options For Polylang plugin?
ACF Options For Polylang is a free WordPress plugin with over 10,000 active installations that automatically handles multilingual ACF options pages. It stores language-specific values in the database and integrates with Polylang's language switcher in the admin. It falls back to the "All languages" value if no language-specific value is set.
Does this approach work with ACF Repeater and Flexible Content fields?
Yes. Pass pll_current_language('slug') as the second parameter to have_rows() for Repeater and Flexible Content fields. Each language's options page stores its own set of rows, so the content is fully independent per language.
Why can't I add ACF fields directly to archive pages?
Archive pages in WordPress are dynamically generated and don't have a corresponding post or page entry in the database. Since ACF fields need a post ID to store data, you need to use an Options Page as a workaround. The options page provides a dedicated place to store and manage fields that apply to archive templates.

Summary

Making ACF Options Pages work with Polylang requires creating separate sub-pages for each language and using the language slug as the post_id. When retrieving fields in your templates, pass pll_current_language('slug') as the second parameter to any ACF function.

For a more automated approach, consider using pll_languages_list() to dynamically detect languages, or the ACF Options For Polylang plugin for a zero-code solution.

Join the Discussion
0 Comments  ]

Leave a Comment

To add code, use the buttons below. For instance, click the PHP button to insert PHP code within the shortcode. If you notice any typos, please let us know!

Savvy WordPress Development official logo