Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function multilingual_post_creation(){
- global $sitepress;
- /**
- /**
- Creating first post in english
- */
- //arguments for post creation
- $def_args = array(
- 'post_title' => '[en]Test post - ' . date("d.m - H:i:s"),
- 'post_content' => 'Text in default language goes here',
- 'post_status' => 'publish',
- 'post_type' => 'post'
- );
- //creating post with arguments above and assign post id to $def_post_id
- $def_post_id = wp_insert_post($def_args);
- $def_trid = $sitepress->get_element_trid($def_post_id);
- /**
- Creating translation of first post in another language. Right now for russian
- */
- //arguments for post creation
- $ru_args = array(
- 'post_title' => '[ru]Test post - ' . date("d.m - H:i:s"),
- 'post_content' => 'Text in russian language goes here',
- 'post_status' => 'publish',
- 'post_type' => 'post'
- );
- //creating post with arguments above and assign post id to $ru_post_id
- $ru_post_id = wp_insert_post($ru_args);
- //change language and trid of second post to match russian and default post trid
- $sitepress->set_element_language_details($ru_post_id, 'post_post', $def_trid, 'ru');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement