For whatever reason wp_insert_post
doesn't work for a custom post type.
Here's the code snippet I'm using.
$new_post = array(
'post_type' => 'rsp_synonym',
'post_title' => wp_strip_all_tags( $row['word'] ),
'post_date' => date('Y-m-d H:i:s'),
'post_author' => 2,
'post_content' => '',
'post_status' => 'publish',
'comment_status' => 'open',
'ping_status' => 'open'
);
$post_id = wp_insert_post( $new_post );
if (is_wp_error($post_id)) {
$errors = $post_id->get_error_messages();
foreach ($errors as $error) {
echo "- " . $error . "<br />";
}
}
Strange enough, it doesn't even return a WP_Error using the if (is_wp_error($post_id))
conditional. But still, no posts are being added.
The custom post type named as rsp_synonym
has been registered before using this call.