How can i create a new post in de default language (english = en) with wpml.
If i use en as languagecode i see a new post on all the languages of wpml.
// Create an array of post details for the new post
$new_post = array(
'post_title' => $titelx, // Parsed post data - Set the title ofthe new post
'post_content' => $inhoudx, // Post content - Set the content ofthe new post
'post_type' => 'post', // Processed post data - Set the posttype to 'post'
'post_status' => 'publish', // Post status - Set the status ofthe new post to 'publish'
'post_author' => 1, // Replace with the desired author's user ID
'post_date' => $datumx, // Post date - Set a custom post date and time
// 'tags_input' => array('tag1', 'tag2', 'tag3'), // Processedttachment post data - Set tags for the new post
// 'page_template' => 'custom-template.php', // Invalid pagetemplate - Set a custom page template for the post
);
// Insert WordPress post into the database
$post_id = wp_insert_post($new_post); // Existing attachment post -Set the existing post ID for updating
// Check if the post was successfully inserted
if (!is_wp_error($post_id)) {
// The post was successfully inserted, and $post_id contains the post ID
// Get the post meta field based on the post ID
$meta_value = get_post_meta($post_id, 'meta_key_name', true);
// Add custom post categories (replace with actual category IDs)
$post_categories = $catid; // Filters attachment post data -Category IDs to assign to the post
wp_set_post_categories($post_id, $post_categories); // Set post categories
// Add custom post meta data
update_post_meta($post_id, '_custom_meta_key', $titelx); // Replace'_custom_meta_key' with your custom meta key and set its value
// Get the post type
$type = get_post_type($post_id);
// Get the translation id (trid)
$trid = wpml_get_content_trid('post_' . $type, $post_id);
// Set the desired language
$language_code = $taalcodex;