Polylang wordpress : creating post from frontend

1.3k Views Asked by At

While working on wordpress I am stuck in polylang plugin.

I have a project in which user create post from frontend. Means If user want to create it as English p1 and German p2 and France p3 then three post for different language will be created .

For assigning language to the post I have use pll_set_post_language($post_id, $lang);

For post relation I didn't find any such function

pll_save_post_translations( $arr );

‘$arr’ => (required) associative array of translations with language code as key and post id as value

But how I will create relation. Means if any unregistered user visit to the website he will see english post, German language post etc respectively language.

Function pll_save_post_translations, there is no way to create relation between p1 p2 or p3.

Thanks

1

There are 1 best solutions below

0
On

According to the documentation , you can use pll_save_post_translations as shown in the example below :

pll_save_post_translations(['en' => p1, 'de'=>p2, 'fr'=>p3]);

‘$arr’ => (required) associative array of translations with language code as key and post id as value