В конце я отсортировал его, написав следующий код:
//Check if category already exists
$cat_ID = get_cat_ID( $category );
//If it doesn't exist create new category
if($cat_ID == 0) {
$cat_name = array('cat_name' => $category);
wp_insert_category($cat_name);
}
//Get ID of category again incase a new one has been created
$new_cat_ID = get_cat_ID($category);
// Create post object
$new_post = array(
'post_title' => $headline,
'post_content' => $body,
'post_excerpt' => $excerpt,
'post_date' => $date,
'post_date_gmt' => $date,
'post_status' => 'publish',
'post_author' => 1,
'post_category' => array($new_cat_ID)
);
// Insert the post into the database
wp_insert_post( $new_post );