Please make sure to update to WPML 4.3.4 before reporting any issue

Hi, Amit here, I am the WPML Support Manager, our current ticket queue is high, update your WPML plugins and make sure you meet the minimal requirements for running WPML before reporting an issue please - many tickets are resolved doing that

Please look at our updated list of Known Issues and you can also use our support search to find helpful information and of course review our documentation before opening a ticket.

If you do need to open a ticket please make sure to provide us with all the needed information as described in this page

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 3 replies, has 2 voices.

Last updated by Konrad Karpieszuk 8 months, 2 weeks ago.

Assigned support staff: Konrad Karpieszuk.

Author Posts
March 6, 2019 at 10:57 am #3278271

sergeyS-14

Hi there!

I got 1000 of imported custom posts en English, posts will use same images as original.

I wold like to copy custom fields form english translation to other languages programmaticaly.

1. Get list of English Posts ID
2. For each post will find this custom fields which is contain ids or images associated with English post in database
3.Duplicate founded custom fields for another languages i have (es,ru,fr).

Is this possible as it is, or shold i know about something because of new Multimedia Translation etс?

Or may be there is some filter or action of WPML what i need to run?

Thank you!

March 7, 2019 at 9:14 am #3283047

Konrad Karpieszuk
Supporter

Languages: English (English )

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

hello

I suggest you one of two approaches. Choose which one is better for you:

prop 1: adjust id during duplication of custom fields
- go to wpml > media and translate every image (you can duplicate them)
- in your custom code for duplicating custom field, before you save id of the image, adjust it using our filter: https://wpml.org/wpml-hook/wpml_object_id/ to get id of translated version of the image

prop 2: adjust id during display of the image
- don't duplicate the images, keep them only in original language
- in your theme, in the place which will display the image wrap it in the code which does:
-- switch temporary language context to original one. for this:
--- save temporary current language to variable with this filter: https://wpml.org/wpml-hook/wpml_current_language/
--- get default language code https://wpml.org/wpml-hook/wpml_default_language/
--- switch to default language with this action https://wpml.org/wpml-hook/wpml_switch_language/ (use language code from previous point)
-- display image from custom field
-- switch back to temporary stored (in first point) current language, again with https://wpml.org/wpml-hook/wpml_switch_language/

I hope I helped 🙂

March 7, 2019 at 4:04 pm #3285652

sergeyS-14

Amazing! Konrad! Very complete answer! Thank you A LOT! I will always ask you if will need)

My issue is resolved now. Instead long writing and asking unnecessary stuff, like access or debug information... You gave me TWO solutions! Thank you so much!

March 8, 2019 at 8:04 am #3289892

Konrad Karpieszuk
Supporter

Languages: English (English )

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

haha, this is nice comment, thank you and I am happy I've helped 🙂