I'm trying to add post to custom terms within a custom taxonomy. Not sure if I'm tackling this right. So far we have the custom taxomony 'warehouse', and the custom term 'Old Stock'.
Problem is that when I try to add the term to the post using the term_id then it creates a new term with the id as a name. Here is the code I'm using:
//add new product $id = @wp_insert_post(array( 'post_title' => $name, 'post_content' => $desc, 'post_status' => 'publish', 'post_parent' => $parent, 'tax_input' => array( array( 'warehouse' => $parent )) ), true); //set terms wp_set_object_terms($id, array($parent), "warehouse");
As you can see I've tried adding the term_id as '
post_parent' as '
tax_input' and also using '
If the term_id was 25, then the above would create a new term called "25"! Instead of sticking the post into the term with an id of 25.
Any help would be appreciated, cheers