Support

Account

Forum Replies Created

  • 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 🙂

  • Thanks James.
    So if the only way is to load the ID of the term I thought a way but I don’t know if its possible.
    The second language on the site is Greek. Greek lang has the ‘el’ language code. When I duplicate the taxonomy for the second language, WPML adds automatically the suffix ‘-el’ on the end of the slug.

    So here is what I thought:

    1)Leave the code as it is
    2)Strip with php the suffix so always will have the same value If the current language is greek.

    So now I’m having this

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

    The $term is an object. Can I load valued based on term slug? If this is possible I can make it work by following the workflow I told you above.

    Thanks

  • Hello James

    Thanks for your response. Yeah I checked that page and also I searched a lot before posting (I’m not the type of guy who posts something without researching first 🙂 )

    Unfortunately nothing solved my issue. The taxonomy fields are stored in database at wp_options right? WPML have fields under Multilingual Content Setup only from wp_postmeta. I need to find a way to have fields from wp_options there (see the 2nd screenshot). Or a way to copy the values.

    Right now as I told you, I have some custom fields inside the product attributes (which product attributes are a custom taxonomy assigned to “Products”). And I just want to copy hundreds of values from the original to translated. Here is a link with someone who had the same issue as me but no explanation given and the topic is closed.

    Thanks again and great great great product btw

Viewing 4 posts - 1 through 4 (of 4 total)