[Resolved] Posts inside a post are not automatically translated
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 -->
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.
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?
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:
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?
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?
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.