wp_insert_post 自定义文章类型的目录问题
The post_category you are using is for core categories taxonomy. For custom taxonomies you have to use tax_input. For example, the next code set terms for custom_tax_category and custom_ta_tag taxonomies.
$args = array(
'post_type' => 'custom_post_type',
'post_title' => wp_strip_all_tags( $title ),
'post_content' => 'some content',
'post_status' => 'publish',
'post_author' => $author_id,
'tax_input' => array(
'custom_tax_category' => array( $category_id ),
'custom_tax_tag' => array( $tag_id )
),
);
$new_cpt_id = wp_insert_post( $args );