WPML 原文章為英文,設定翻譯語言為中文

$chinese_post_id = 4719;
$post_type = 'investor';
$english_post_id = 2787560;
$trid = apply_filters( 'wpml_element_trid', NULL, $english_post_id, 'post_' . $post_type )

$set_language_args = array(
    'element_id'   => $chinese_post_id,
    'element_type' => 'post_' . $post_type,
    'trid'         => $trid,
    'language_code' => 'zh-hant', // Language code for Tranditional Chinese
    'source_language_code' => 'en' // Source language code, English in this case
);

do_action('wpml_set_element_language_details', $set_language_args);