Home › Forums › General Issues › How to display default language Options field, when no WPML translation exists › Reply To: How to display default language Options field, when no WPML translation exists
I am trying to create my own function as follows, to replace the_sub_field() in the template, but it returns the value twice.
function the_sub_field_wpml($field)
{
$the_value = the_sub_field($field);
if($the_value == '' || !$the_value)
{
//set the current language to EN temporarily
add_filter('acf/settings/current_language', function(){return 'en';});
$the_value = the_sub_field($field);
//set it back to DE
add_filter('acf/settings/current_language', function(){return 'de';});
}
return $the_value;
}
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.