Support » Plugin: Polylang » Programmatically set post language and translations

  • Resolved Compute


    I’m using WP All Import to migrate articles from another site to the new one. But I’m having a hard time to programmatically set a language to a specified post and update the posts translations.

    Trying to update post language from pll_set_post_language(), but Polylang’s save_post hooks seems to overrule that one.

    Are there any good ways to programmatically update post language and translations or do I have to update all translations at once (like in the save_post hook in admin-filters-post)?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Ended up using a mix of pll_save_post (that sends translations) and pll_save_post_translations.

    where do you found : pll_save_post ?
    I don’t see it in the documentation?

    Polylang has an api.php file which cover all the api functions for the plugin. Its not documented but I was just looking inside the code.

    Hi @compute

    Could you share how did you solve this? I’m using wp all import too, and i’m working for a solution to set post translations with pll_save_post_translations, and it will help me to solve this.
    My code sometimes works but sometimes is like overwrites all the translation of the post and only sets the original language


    I just hooked into the action of pll_save_post that runs after Polylang has set the language. After that I set the languge by using pll_set_post_language on the post and pll_save_post_translations to save the translations aswell.



    @compute, can you share solution in this topic too? Because it is quite hard to write and change cod

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Programmatically set post language and translations’ is closed to new replies.