Support

Account

Home Forums ACF PRO Fields in custom Taxonomy and WPML translation management Reply To: Fields in custom Taxonomy and WPML translation management

  • Hello again James. I solved my issue by getting the default language (english) term object. It works flawlessly (I’m a little noob on PHP so I need your opinion on this)

    Here is the function which takes the defaults language current term object (Credits)

    function get_term_for_default_lang( $term, $taxonomy ) {
    
        global $sitepress;
        global $icl_adjust_id_url_filter_off;
    
        $term_id = is_int( $term ) ? $term : $term->term_id;
    
        $default_term_id = (int) icl_object_id( $term_id, $taxonomy, true, $sitepress->get_default_language() );
    
        $orig_flag_value = $icl_adjust_id_url_filter_off;
    
        $icl_adjust_id_url_filter_off = true;
        $term = get_term( $default_term_id, $taxonomy );
        $icl_adjust_id_url_filter_off = $orig_flag_value;
    
        return $term;
    }

    And here is on use:

    
    $term_default = get_term_for_default_lang( $term, $taxonomy );
    $us_size = get_field('us_' . $productBrandSlug[0], $term_default);
    $uk_size = get_field('uk_' . $productBrandSlug[0], $term_default);
    

    If anyone has the same problem as me and doesn’t want to manually fill up hundreds of fields you can use the above function 🙂