This thread is resolved. Here is a description of the problem and solution.
Problem:
I would like to use Rest API with WPML to manage posts / pages
Solution:
Creating post and page translation using Rest API is not tightly integrated with WPML yet, You can use language parameter to create translation (?lang=fr) however it will still need some custom work to connect the translation with the original content of the post / page.
There is a workaround but you need to implement it . A wpml user shared this before sometime ago, other users reported that is working great, but have in mind that this is not coming from WPML so we cannot support it:
---------------
Finally i created a custom endpoint to link the 2 translations.
This is my code : https://gist.github.com/djoo/5518bcf4ccef93ab83d91787c41e929a
So the process is :
1- create the first post in language 1 (classic API POST call)
2- create the second post in language 2 (classic API POST call)
3- link both (custom endpoint)
Hope is gonna help people
---------------
You can use our hooks to add a few more functionalities: https://wpml.org/documentation/support/wpml-coding-api/wpml-hooks-reference/
NOTE: While this is a great workaround always have a backup in place when using custom code either provided by us or another member of this 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 3 replies, has 2 voices.
Last updated by 2 years, 9 months ago.
Assisted by: Andreas.