Background of the issue:
I would like to enable automatic translation for a specific custom post type: Product. Posts and pages contain manually created content, which should not be automatically translated. However, products are imported into our site via an API, and therefore should be translated automatically.
Symptoms:
Previous support articles contain outdated information or settings not available anymore.
Questions:
How can I enable automatic translation for a specific custom post type in WPML, and disable it for all other content?
Reference our recent chat I've moved to this ticket as requested.
Unfortunately there's no out of the box supported way of setting a specific post type for automatic translation. The prescribed method is as the following:
- Do not turn on "Translate Everything" mode.
- Select the content you want to translate automatically in WPML -> Translation Dashboard.
- And scroll down to end of the page and select translate automatically and send for translations (https://wpml.org/documentation/translating-your-contents/).
I'm sorry to hear that. We are (very) experienced in PHP. Is there no filter or hook that WPML runs when an item is about to be sent for automatic translation? If that were possible, I could modify the selection there and make sure only posts of type 'product' were passed?
The possibility to disable automatic translation for a CPT using that XML is great, but I'm unsure if the xml '<custom-types>' attribute also support 'post' and 'page' as value, because we would have to disable those.
Would you know if that is the case?
---
Possible solution 2 - Custom cron action
Alternatively, I could imagine we would be able to build a function that runs periodically and does the following:
1. Retrieve untranslated recent products (wp_query)
2. Foreach product, trigger WPML to translate it automatically.
Could you help me with item 2. Is there a method we can call to trigger automatic translation for a certain post ID to certain/all languages? Even though 'translate everything automatically' is turned off?
Unfortunately there's no such hook or method available in public API to trigger automatic translation for now.
However, after discussing with some colleagues, I'll file it as a feature request in our system. At this point we can't promise that if it is approved and if approved then how long it takes to roll out.
Thank you for your patience and cooperation. I've registered this as a feature request in our systems and have escalated the matter to our 2nd tier team.
I'll update you if there's more to it, however, as noted earlier, it may take time if accepted.