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


Fields in custom Taxonomy and WPML translation management

  • Hello! I’m building an eshop, on which I’m using ACF to have some custom fields on Product Attributes in Woocommerce (which product attributes are custom taxonomy). Specifically, I have some shoe sizes as attributes. On each attribute I added some fields to specify the different region sizes from shoes (UK, US, CM), so on the front end the user can convert the sizes to his region (see screenshot). Everything works perfect except the WPML part. WPML requires to translate the attributes. I will have hundreds of sizes and assigned to them hundreds of fields.

    I need to find a way to have those fields to “Copy from original to translation” from Translation Management.

    Right now WPML finds fields which are only at posts or pages, not from Taxonomies or Options. How can tweak it to find those fields and add them to Translation Management?

    Thank you


    I expect to see the fields here, but here shows only fields from posts/pages

  • Hi @hambos22

    Have you checked this page about multilingual custom field:

    If you want, you can also get the custom field value from the original post by providing the second parameter like this:

    $value = get_field( "text_field", 123 );

    This page should give you more idea about it:

    I hope this helps.

  • 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

  • Hi @hambos22

    If you have tried other methods and still couldn’t find the solution, I believe you need to update the custom fields manually for the translated post or just use the values from the original post.

    The problem is, how to get the original post ID from the translated post. If you can get the ID, you can get the values by providing it as the second parameter on the get_field() function like I told you before. Keep in mind that taxonomy has a different method to do it. This page should give you more idea about it: This way, you only need to manage the custom fields on the original posts/taxonomies.

    Another approach would be generating the custom field values when you saved the translated post. You can use the update_field() function in the acf/save_post hook. Just like the first method, you need to get the ID of the original post.

    I hope this makes sense.

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


  • Hi @hambos22

    Unfortunately, you need to set the second parameter with the taxonomy name and the term ID like this:

    get_field('us_' . $productBrandSlug[0], 'taxonomy-name_99');

    Where 99 is the ID of the term. This page should give you more idea about it: Maybe you can use the get_term_by() function.

    I hope this helps.

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

  • Hi @hambos22

    I’m not familiar with WPML features and functions, but your function looks great for me. Glad that you solved this issue.

    I hope the others can benefit from your post or suggest a better method id they know 🙂


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

The topic ‘Fields in custom Taxonomy and WPML translation management’ is closed to new replies.