|
↳ See all 15 articles
/ Documentation /Troubleshooting/ Astra Customizer Strings Reverting to Wrong Language with WPML

Astra Customizer Strings Reverting to Wrong Language with WPML

When using WPML with different languages set for the WordPress admin and the site frontend, Astra Customizer text strings may revert to the admin language after saving, even if the correct frontend language was set. This doc explains how to resolve it with a targeted code snippet.


When Does This Happen?

This issue occurs when all three of the following are true:

  • The WPML plugin is active on your site
  • Your WordPress admin language is set to a different language than your site’s frontend language (for example, admin in Spanish, frontend in English)
  • You save text strings in Appearance > Customize — such as button labels, copyright text, or header/footer strings

After saving, those strings may display in the admin language on the frontend instead of the site language.

Note:

This affects both the free version of Astra and Astra Pro.


Before You Begin

Before applying the fix, confirm the following:

  • Astra is updated to the latest version
  • WPML is updated to the latest version
  • Site cache and browser cache have been cleared

The Fix

The recommended fix is a small code snippet added to your child theme. It ensures Astra uses the correct frontend language when loading Customizer strings, and only runs inside the WordPress admin and Customizer, never on frontend pages.

Step 1 — Add the Code to Your Child Theme

  1. In your WordPress dashboard, go to Appearance > Theme File Editor.
  2. In the right-hand file list, select your child theme’s functions.php file.
  3. Add the following code at the end of the file:
/**
 * Fix: Astra Customizer default strings use site locale instead of admin locale.
 * Required when using WPML with different admin and site languages.
 */
$astra_locale_switched = false;

add_action(
    'after_setup_theme',
    function () use ( &$astra_locale_switched ) {
        if ( ! is_admin() && ! is_customize_preview() ) {
            return;
        }
        $site_locale = get_option( 'WPLANG' ) ?: 'en_US';
        if ( determine_locale() !== $site_locale ) {
            $astra_locale_switched = (bool) switch_to_locale( $site_locale );
        }
    },
    9
);

add_action(
    'after_setup_theme',
    function () use ( &$astra_locale_switched ) {
        if ( $astra_locale_switched ) {
            restore_previous_locale();
            $astra_locale_switched = false;
        }
    },
    11
);
  1. Click Update File to save.

Note:

Don’t have a child theme? It’s recommended to create one before adding custom code. See How to Create a Child Theme for Astra.

Step 2 — Verify the Fix

  1. Go to Appearance > Customize.
  2. Navigate to a section that contains text strings (for example, Header >Button).
  3. Update a text string and click Publish.
  4. Visit the frontend of your site and confirm the text displays in the correct language.

Expected Outcome

After adding the snippet, text strings saved in the Customizer will display in the site’s frontend language, regardless of the language set for the WordPress admin.


Important Notes

  • The snippet must remain in place permanently. Removing it will cause the issue to return.
  • It is safe to leave in your child theme long-term. The is_admin() || is_customize_preview() guard ensures it only runs in the admin and Customizer, never on frontend pages.
  • This fix covers all Astra Customizer strings, including any added in future Astra updates, without needing to modify the snippet.
  • If you manage multiple sites with the same WPML + language setup, the snippet needs to be added to each site’s child theme individually.

Still Not Resolved?

If the issue persists after adding the snippet, reach out via the Astra Support Portal with the following details:

  • WordPress version
  • Astra version
  • WPML version
  • Admin language and site frontend language settings
  • A screen recording showing the exact steps that trigger the issue

Related Docs

Was this doc helpful?
What went wrong?

We don't respond to the article feedback, we use it to improve our support content.

Need help? Contact Support
Scroll to Top