Skip to content Skip to sidebar

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

Problem:
The client is experiencing issues with translating nested Custom Post Types (CPTs) such as 'quote' or 'contact-person' within a parent CPT post using ACF Pro and WPML. Even though these nested CPTs are translated, they do not always display in the translated version of the parent CPT.
Solution:
We recommended adding specific HTML to the Gutenberg block code to make the nested CPTs translatable. Here is the code that needs to be added:

<!-- wp:acf/contact {"name":"acf/contact","data":{"block_margin":"margin_default","_block_margin":"field_632ad768f82b2","block_margin2":"","_block_margin2":"field_66226c6c5c17f","composition":"select-contactperson","_composition":"field_662672b951a80","select-contactperson":2342,"_select-contactperson":"field_663cbb0667643"},"mode":"auto"} /--><br /><div class="abcd">here is the block content</div><br /><!-- end block settings wp:acf/contact -->

After adding this HTML, the client must register the block for translation by following the steps in this guide: https://wpml.org/documentation/support/language-configuration-files/make-custom-gutenberg-blocks-translatable/
Additionally, the client can create a language configuration file manually if needed.

If this solution does not resolve the issue or seems outdated, we 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 our 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 6 replies, has 2 voices.

Last updated by Carlos Rojas 1 year, 7 months ago.

Assisted by: Carlos Rojas.

Author Posts
July 4, 2024 at 8:19 am

joostv-32

Background of the issue:
On our client's website hidden link, we noticed that if we try to translate a CPT post from Dutch to English, those posts inside that certain CPT post are not translated always. The posts inside the CPT post are also CPT posts itself, like a quote or contact-person. The CPT posts like quote or contact-person are already translated, but the translated version is not showing up sometimes at the parent CPT post. We use the ACF (Pro) plugin and of course the Advanced Custom Fields Multilingual plugin. We already raised the memory in wp-config.php, it did not solve the problem.

Symptoms:
The translated version of CPT posts like quote or contact-person is not showing up sometimes at the parent CPT post.

Questions:
Why are the translated CPT posts like quote or contact-person not showing up at the parent CPT post?
Is there a specific configuration needed in WPML to ensure that nested CPT posts are translated correctly?

July 4, 2024 at 9:20 am #15890536

Carlos Rojas
WPML Supporter since 03/2017

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

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

Hi there,
Here is the forum ticket where we will continue.

I have set your next message private so you can securely share the access credentials to the staging site.

Regards!

July 8, 2024 at 8:33 am #15911042

Carlos Rojas
WPML Supporter since 03/2017

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

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

Hi,
Thank you for sharing the credentials!

I have consulted my colleagues about this issue and there is a workaround. To be able to automatically translate the ID of the CPT you need to add some HTML to the code of the block, that way you will be able to register the block for WPML.

Right now, the code generated by the Gutenberg block when editing the page in the original language is:

<!-- wp:acf/contact {"name":"acf/contact","data":{"block_margin":"margin_default","_block_margin":"field_632ad768f82b2","block_margin2":"","_block_margin2":"field_66226c6c5c17f","composition":"select-contactperson","_composition":"field_662672b951a80","select-contactperson":2342,"_select-contactperson":"field_663cbb0667643"},"mode":"auto"} /-->

And you must add some HTML (later you can hide it with CSS) like:

<!-- wp:acf/contact {"name":"acf/contact","data":{"block_margin":"margin_default","_block_margin":"field_632ad768f82b2","block_margin2":"","_block_margin2":"field_66226c6c5c17f","composition":"select-contactperson","_composition":"field_662672b951a80","select-contactperson":2342,"_select-contactperson":"field_663cbb0667643"},"mode":"auto"} /-->

<div class="abcd">here is the block content</div>

<!-- end block settings wp:acf/contact -->

Once you have made that change, then you must register the block by following the steps described in this guide: https://wpml.org/documentation/support/language-configuration-files/make-custom-gutenberg-blocks-translatable/

July 8, 2024 at 9:56 am #15912107

joostv-32

Thank you for your reply.

This doesn't look like a workable solution. So now I need to add the HTML manually to every block in Gutenberg that doesn't want to be translated? I made the blocks with ACF, is it possible to automatically place that HTML code during initialization of those blocks?

And also: can I just make a wpml-config.xml myself? Without using the bloated Multilingual Tools? This tool should also not used on production/live sites WPML says. But the solution should ofcourse also be applied on the live-site, so can I just make the wpml-config.xml myself?

July 8, 2024 at 9:59 am #15912168

Carlos Rojas
WPML Supporter since 03/2017

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

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

Hi there,

Yes, you can add the HTML in the initialization of those blocks.

And yes, you can create the language configuration file yourself, the tool is used as help to identify all possible fields in the blocks 🙂

July 11, 2024 at 7:49 am #15933134

joostv-32

So if I install that workaround correctly, I can translate the field "select-contactperson" from id 2342 to the corresponding English id in the WPML Translation Editor? (hidden link)

That's not really user-friendly right? Because the content editor needs to know the English version id of the contact-person. Isn't it possible to somehow automatically translate the select-contactperson field?

July 11, 2024 at 10:35 am #15934267

Carlos Rojas
WPML Supporter since 03/2017

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

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

Hi there,

Unfortunately, this workaround is the only option we have right now to make it work, because the numeric fields are automatically copied to the secondary language. Our specialists are constantly working on fixing issues and improving compatibility so I'd recommend you check our newsletter from time to time to check if the solution to this issue is already available.