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

Last updated by Yvette 2 years, 10 months ago.

Assigned support staff: Yvette.

Author Posts
October 23, 2017 at 9:10 am #1408411


I am trying to: use WPML translation editor to translate a custom post type with ACF PRO Relationship field. I would like the relationship field to "translate" the relationship picking post ID from the right language

Link to a page where the issue can be seen: not online, I'm on a local test installation

I expected to see: I set the relationship field as "copy", I expect WPML to get the post object (or ID) from tranlslated posts.

Instead, I got: I always see the original language post object (or ID), not the translated one.


This is how i do:

1) create a custom post type (ex: movies)
2) create a second CPT (ex: actors)
3) create an ACF relationship field for movies CPT, that picks Actors CPT
4) in Translation management-> multilingual content Setup -> Custom Field Translation, I set Actors Relationship field on "COPY"
5) create an actor post and translate it in a secondary language
6) create a movie post and add a relationship with the actor post
7) translate the movie post using WPML translation editor (the relationship field is not present, as I would expect because is set on "copy")
8) check translated movie using standard WordPress edit post screen: in relationship field, I don't see a relation with the translated actor, but always with the main language one.

is this standard behaviour?


I'm on a test installation,
no other plugins installed (just ACF PRO, WPML suite, and ACFML),
using default Twenty seventeen theme
everything is up to latest version.

October 24, 2017 at 4:28 pm #1410366


Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+02:00)


I will be helping you with this issue.

Thanks for providing the detailed steps to replicate this issue. I will be following this on my test local system.

In the meantime, please provide information about your environment by following thsese steps:

Thank you.

October 24, 2017 at 6:46 pm #1410510


I posted debug info of my testing enviroment.

October 26, 2017 at 12:39 pm #1412886


Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+02:00)


Sorry for the delay in responding.

The system is behaving as it should. There should be a distinction made between what WPML will do with the custom field and what ACF can do.

WPML will ensure that the custom field is available in the post-meta of the post type if the multilingual content settings for the field is either "Translate" or "Copy".

If the value is set to "Copy", that post-meta field will always be synchronised with the original language contents of the same post-meta field in the original post. This is the behaviour you are seeing.

If the value is set to "Translate", then the post-meta field is created for the post but it will be empty so that a "translated" value will can be inserted. The Translation Editor / WordPress native editor, will present this field when creating the translated post type. Normally, through the translation process, you would then select a relational object from the list of translated "actors" custom post types.

I think it would be best to think that the field becomes "translatable" and not to think the field will be "translated".

What you want to do, if I understand correctly, is to prefill this translated field box with the "translated" value of the object that was selected in the original "Movie" post. In short, this is not within the scope of ACFML.

To do this, you would need to add the functionality as described in this post:
hidden link
However, instead of calling the get_the_title() function you would create your own function that would do something like this:
1. Retrieve the custom field value in the original "Movie" post.
2. Call wpml_object_id for the target language
3. Return the translated Actor object_id so it could be prefilled.

Here is more on this hook:

As you can see, it is not such a trivial thing.

Have I been able to answer your question?

October 26, 2017 at 1:12 pm #1412945


Hello Yvette,
I'm not sure if i understand what you mean.

The field I'm talking about is not a text field. It's not something I can translate.
It's a relationship field, that saves in database the ID of a post (actor), choosen from the ACF interface for "Post Object" or "relationship" field (present on the movie post edit screen).

What I would like to achieve is that, using the WPML translation editor to edit e Movie, if the related actor has a translation, on the Movie in second language the Actor post ID should not be the Actor of the main language, but the translated one.

maybe I'm still confusing.

an example:

I have a Movie post: the Godfather
in this post I have a relationship fields where I choose to associate an actor (that is another post type): Marlon Brando

Now I translate Marlon Brando in Italian, and I call him Marlon Brando ITA

Then I translate the movie: The Godfather ITA, using the WPML translation editor.
But in the relationship field of "actor" I find "Marlon Brando" instead of "Marlon Brando ITA".

This behaviour forces me to use the standard wordpress editor to choose the right Marlon Brando. While i would like to automate this, so that I can use the WPML translation editor.

I set this on "copy", because there's nothing to "translate", the translation has already been made. i just want to attach the translated Brando ID, on the translated Movie.

is this something not achievable using WPML out of the box?

October 26, 2017 at 1:40 pm #1412994


Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+02:00)

I understood your situation perfectly the first time. I created an example in my own test system with "Meryl Streep" / "Meryl Streep ES" and translated movie "The Dearhunter" / "El cazador de ciervos"

You wrote this: "..While i would like to automate this, so that I can use the WPML translation editor...."

The only way to automate this field population is to write a special script like what is described here:
hidden link

You are confusing the word "Translate" in this case with pre-filling a custom field value at time of translation. You need to assimilate that marking a custom field as "Translate" in the WPML-sense is to make the custom field available in a 2nd language. The only thing that gets automatically translated is the custom field label if you have translated the field group properly.

Please don´t confuse the custom field itself with the value it might hold. What you are trying to do is not possible with WPML.

October 26, 2017 at 2:16 pm #1413063


Sorry but i still don't understand why you keep telling me about prefilling.

I want to use WPML Translation editor!

so, if this functionality ("auto-translation" of a relationship field) does not exist, is there an hook in translation editor I can use (when saving translation) to programmatically update that fields in the second language?

October 27, 2017 at 11:11 am #1413959


Languages: English (English ) Spanish (Español )

Timezone: Europe/Madrid (GMT+02:00)


I still don´t have an answer about the action hook for the TE. However, I had a conversation with the ACFML developer and tested some suggestions from him.

We can get close to the workflow you want/need if you first start by "duplicating" the post type "Movie".

If your realationship field is called "relationship_field", then the translation options for the following custom fields shoudl be set like this:
relationship_field => translate
_relationship_field => copy

The workflow would be like this:

1. Duplicate your Movie "The Godfather" to IT ( you can do this in the native wordpress editor or via the Translation Dashboard)
2. Then edit the IT duplicate "The Godfather" with Translation editor
3. The action of "Translating independently" will adjust the object id of the custom field as you are expecting.
4. However, it will show up in the Tranlsation Editor as a translatable field (e.g. you will see it in the editor but it will have the translated object id for "Marlon Brando IT".

This is the closest you will get to an "automatic translation" at the moment.
Do you think this will meet your needs?

The topic ‘[Closed] How to translate/copy ACF Relationship Fields?’ is closed to new replies.