Created
November 11, 2013 11:07
-
-
Save Zenger/7411575 to your computer and use it in GitHub Desktop.
wp_insert_post and WPML
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
global $wpdb; | |
// Insert the original post | |
$original = wp_insert_post($array, true); | |
// Insert the translated post | |
$translated = wp_insert_post($array, true); | |
// Make some updates to both translations | |
update_post_meta(); | |
wp_set_object_terms(); | |
// ... and so on | |
// Associate translated language and original language | |
$trid = wpml_get_content_trid('post_<your_custom_post_type>', $original ); | |
$wpdb->update( $wpdb->prefix.'icl_translations', array( 'trid' => $trid, 'language_code' => '<your_language_code>', 'source_language_code' => wpml_get_default_language() ), array( 'element_id' => $translated ) ); | |
// That's it |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment