Support

Account

Home Forums ACF PRO WPML, ACF 5.0.9 and Options Page Reply To: WPML, ACF 5.0.9 and Options Page

  • I’ve made some modifications so I’m not limited to a single get_field wrapper function, and you don’t have to put the filter code in your page template.

    <?php
    
    /**
     * functions.php
     */
    
    if ( !function_exists( 'yourprefix_acf_get_language_default' ) )
    {
        function yourprefix_acf_get_language_default()
        {
            return acf_get_setting( 'default_language' );
        }
    }
    
    if ( !function_exists( 'yourprefix_acf_set_language_to_default' ) )
    {
        function yourprefix_acf_set_language_to_default()
        {
            add_filter( 'acf/settings/current_language', 'yourprefix_acf_get_language_default', 100 );
        }
    }
    
    if ( !function_exists( 'yourprefix_acf_unset_language_to_default' ) )
    {
        function yourprefix_acf_unset_language_to_default()
        {
            remove_filter( 'acf/settings/current_language', 'yourprefix_acf_get_language_default', 100 );
        }
    }
    
    /**
     * page template
     */
    
    yourprefix_acf_set_language_to_default();
    
    // use any acf function like normal
    
    yourprefix_acf_unset_language_to_default();