Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
You are developing a site and want to use the REST API to translate categories and terms in WPML.
Solution:
We recommend using the WooCommerce API to create categories and terms and add translations to existing ones. For detailed guidance, please refer to our documentation on using the WordPress REST API with WooCommerce Multilingual. You can find it here: Using WordPress REST API with WooCommerce Multilingual.

Here are a few examples:

$category = [ 'name' => 'Product Category ES', 'translation_of' => $original_category_id, 'lang' => 'es' ];<br />$woocommerce->post( 'products/categories', $product_category );
$attribute_term = [ 'name' => 'Black ES', 'translation_of' => $original_attribute_term_id, 'lang' => 'es' ];<br />$woocommerce->post( 'products/attributes/{$attribute_id}/terms', $attribute_term );

If this solution does not resolve your issue, or if it seems outdated or irrelevant to your case, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If further assistance is needed, please open a new support ticket at WPML support forum.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 2 replies, has 2 voices.

Last updated by Mateus Getulio 3 months, 3 weeks ago.

Assisted by: Mateus Getulio.

Author Posts
July 22, 2024 at 2:10 pm #15987334

elinaB-3

Background of the issue:
I am developing a site and want to use the REST API to translate categories and terms.

Symptoms:
No specific issue or error message mentioned.

Questions:
How can I use the REST API to translate categories in WPML?
How can I use the REST API to translate terms in WPML?

July 22, 2024 at 2:12 pm #15987343

elinaB-3

i have translated products succesfuly with REST API (using woocommerce API) , but now i need to translate also categories.

i wonder if it is possble with REST API or php API

July 22, 2024 at 7:30 pm #15988937

Mateus Getulio
Supporter

Languages: English (English ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello there.

It is possible to use the WooCommerce API to create categories and terms and add translations to existing ones by consequence.

Please check our documentation with examples to see if it helps you:

https://wpml.org/documentation/related-projects/woocommerce-multilingual/using-wordpress-rest-api-woocommerce-multilingual/#creating-taxonomy-terms-product-category-tag-attribute-shipping-class

Please check a few examples:

Category:

$category = [ 'name' => 'Product Category ES', 'translation_of' => $original_category_id, 'lang' => 'es' ];
$woocommerce->post( 'products/categories', $product_category );

Term:

$attribute_term = [ 'name' => 'Black ES', 'translation_of' => $original_attribute_term_id, 'lang' => 'es' ];
$woocommerce->post( 'products/attributes/{$attribute_id}/terms', $attribute_term );

Thank you,
Mateus