Solved it on my own…
$newPost = array(
'post_title' => "Translated title",
'post_content' => "Text to publish",
'post_status' => 'publish',
'post_type' => 'translation',
'comment_status'=> 'closed',
'post_author' => 1
);
// Create post, save the resulting ID
$new_post = wp_insert_post($newPost, false);
$parent = '2'; // id of original article
add_post_meta( $new_post, 'mealingua_translations_post_id', $parent, true );
$languageCode = "de"; //whatever language of the translation
$term_id = term_exists( $languageCode, 'languages' ); // Get the term ID of language
if($term_id){ wp_set_post_terms( $new_post, $term_id['term_id'], 'languages', true ); }
-
This reply was modified 8 years, 5 months ago by Firstcode.
-
This reply was modified 8 years, 5 months ago by Firstcode.