Support

Account

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;
    }