Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save senlin/4fd15ba7a19533ceb9fe to your computer and use it in GitHub Desktop.
Save senlin/4fd15ba7a19533ceb9fe to your computer and use it in GitHub Desktop.
How to get language independent ACF theme options on a WPML site
<?php
/**
* To get this to work, you need to tinker with the acf/settings/ filter and reset the default language
* so that the get_field() function returns the correct results even when not on the default language.
*
* You can add the filter before you call the get_field() function and then call it again with the current
* language to reset it again, so it will affect other pages.
*
* answer courtesy of James of ACF Support
*/
// add this
add_filter( 'acf/settings/current_language', function() {
global $sitepress;
return $sitepress->get_default_language();
});
// this is already in your code
$my_field = get_field( 'my_field', 'option' );
// reset to original language
add_filter( 'acf/settings/current_language', function() {
return ICL_LANGUAGE_CODE;
});
@MarcGuay
Copy link

MarcGuay commented Jul 10, 2025

Currently, you can access the different language versions of options like so: get_field('selector_here', 'options_en') where 'en' is replaced by your desired language code. Note the 's' on 'options'. The default language is stored under 'option' like so get_field('selector_here', 'option')

@graham73may
Copy link

@MarcGuay 😱 How long has that been a feature?(!)

@MarcGuay
Copy link

MarcGuay commented Jul 15, 2025

@graham73may
Copy link

Awesome, thanks!

@MarcGuay
Copy link

Kind of tragic that it's not documented since there's so many people trying to solve this via painful methods.

@senlin
Copy link
Author

senlin commented Jul 15, 2025

Kind of tragic that it's not documented since there's so many people trying to solve this via painful methods.

👆 this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment