I'm creating new categories with galleries taxonomy :
$wpdb->insert("wpem_terms", array(
'name'=>'Custom Category',
'slug'=>'customcategory',
'term_group'=>0,
));
//id of term
$id = $wpdb->insert_id;
$wpdb->insert("wpem_term_taxonomy", array(
'term_id'=>$id,
'taxonomy'=>'galleries',
'description'=>'',
'parent'=>'',
'count'=>'',
));
It's working. And then i'm trying to publish a new post with this newly created category :
wp_insert_post(array(
'post_author'=>1,
'post_date'=>date('Y-m-d H:i:s'),
'post_date_gmt'=>date('Y-m-d H:i:s'),
'post_content'=>'',
'post_title'=>'',
'post_excerpt'=>'',
'post_status'=>'publish',
'comment_status'=>'closed',
'post_name'=>'',
'post_parent'=>0,
'post_type'=>'portfolio', // with 'portfolio' custom post type
'post_category'=>array($id),
));
This is publishing post , it's OK but post's category isn't Custom Category . I think this line invalid :
'post_category'=>array($id),
Any ideas? Also i tried this :
'post_category'=>array(get_cat_ID("Custom Category")),

'post_category'=>array(intval($id)),do you still get the same problem? – Jared Jan 17 '12 at 16:38array(intval($id))– Eray Jan 17 '12 at 16:41