Skip Navigation

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 1 reply, has 2 voices.

Last updated by Dražen 1 year, 3 months ago.

Author Posts
September 15, 2023 at 7:53 pm #14405373

ruikaiW

Hi,

I have a site with 2 languages , EN as primary and ES as secondary

I have a product in both EN/ES language , they have product/post ID as 77, 81 , respectively

and from the frontend , they belong to a category , where EN product linked to category ID 18 , and ES product to cat ID 27

this is the background story

so , if I run this

`get_the_terms(77, 'product_cat');`

it returns 18 , this is correct and expected , English product ID gives English category ID

however, if I do it on post ID 81 , it still gives me category ID 18 , where I would expect it be 27 which is the Spanish category ID

is there any hook from WPML to get this ? I saw there is something for product/post , but couldn't find any about categories

Best regards,

September 18, 2023 at 6:53 am #14409337

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+01:00)

Hello,

you can try using the next hooks from WPML:

- https://wpml.org/wpml-hook/wpml_object_id/
- https://wpml.org/wpml-hook/wpml_get_element_translations/

Please check next ticket for more info:
- https://wpml.org/forums/topic/regarding-get_terms-function-in-multiple-language/#post-10983825

Hope it helps.
Drazen

The topic ‘[Closed] how get linked category IDs of a translated product/post ?’ is closed to new replies.