Quantcast
Channel: polylang – WordPress.org Forums
Viewing all articles
Browse latest Browse all 11471

Chouby on "[Plugin: Polylang] Best way to pragmatically add a post in a language?"

$
0
0

That should work:

global $polylang;

$post = array (
	'post_author' => $user_id,
	'post_type' => 'jnet_member'
);
$result_en = wp_insert_post ( $post, true );
$result_ja = wp_insert_post ( $post, true );

$polylang->model->set_post_language($result_en, 'en');
$polylang->model->set_post_language($result_ja, 'ja');
$polylang->model->save_translations('post', $result_ja, array('en' => $result_en));

Viewing all articles
Browse latest Browse all 11471


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>