Home › Forums › Add-ons › Options Page › WPML and ACF Options › Reply To: WPML and ACF Options
A little correction for the previous function
function get_field_wpml( $field_key, $post_id = false, $format_value = true ) {
// see : http://support.advancedcustomfields.com/forums/topic/wpml-and-acf-options/
global $sitepress;
$is_cascade = $post_id == 'option' && $format_value == true ? true : false;
$format_value = $post_id == 'option' ? true : $format_value; // force $format_value = true for option
// get field for default language
if ( ( $sitepress->get_default_language() == ICL_LANGUAGE_CODE ) && ( $ret = get_field( $field_key, $post_id, $format_value ) ) ) {
return $ret;
}
// get field for current language
elseif ( $ret = get_field( $field_key . '_' . ICL_LANGUAGE_CODE, $post_id, $format_value ) ) {
return $ret;
}
// get field when if not exists for locale by cascade
elseif ( $is_cascade ) {
return get_field( $field_key, $post_id, $format_value );
}
return false;
}
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.