I am in trouble. I have a travel site…I have created a page where users can write a form to insert their houses.

The houses are of course a custom post type.

This is a piece of my code:

...
some validation here

if ($idarticolo = wp_insert_post($post)) {

    //lingua
    global $polylang;
    $lang = pll_current_language();
    $polylang->set_post_language($idarticolo, $lang);

    ...

everything works fine, the house is inserted in my current language; but when I try to translate this post from admin panel, I get an error.

The post is not translated, and no language is detected.

Please help!!!…many thanks in advance!

M.:)

3 Answers
3

Apparently Polylang has an undocumented pll_save_post API method. See here: https://wordpress.org/support/topic/programmatically-set-post-language-and-translations

Leave a Reply

Your email address will not be published. Required fields are marked *