Home › Forums › Add-ons › Options Page › Don't translate option page › Reply To: Don't translate option page
A little addition, although it’s an older topic.
I needed this as well, but as @andreasdm mentioned already, it needs to added ‘around’ each option that you retrieve.
So I made it a bit easier, so you don’t have to add this around each get option field you use. I made a custom function (which needs to be added in functions.php) which returns the original value, based on the field name that is inputted.
/**
* Force return default language option value
*
* @param bool $field_name
*
* @return bool|mixed|null
*/
function beee_get_filtered_option( $field_name = false ) {
if ( false == $field_name ) {
return $field_name;
}
/**
* Set language to default
*
* @return bool|mixed
*/
function beee_set_default_lang() {
global $sitepress;
return $sitepress->get_default_language();
}
add_filter( 'acf/settings/current_language', 'beee_set_default_lang' );
// retrieve $field_name option value
$value = get_field( $field_name, 'option' );
/**
* Reset to 'real' language
*
* @return mixed
*/
function beee_reset_to_real_lang() {
return ICL_LANGUAGE_CODE;
}
add_filter( 'acf/settings/current_language', 'beee_reset_to_real_lang' );
return $value;
}
if ( class_exists( 'acf' ) ) {
add_action( 'init', 'sd_get_filtered_option' );
}
Add this as is. No changes needed.
Then call each option value like this:
beee_get_filtered_option( $option_field_name );
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.