I tried to add a category based on a post as seen on this link:
How we add new categories by wp_insert_post
Here, I added 'post_category' and default category IDs in an array as shown below:
$my_post = array( 'post_title' => 'test', 'post_content' => 'hello', 'post_status' => 'publish', 'post_author' => 1, 'post_type' => 'product', 'post_category' => array(2,3,4,5) ); $post_id = wp_insert_post($my_post);
All of the fields above have been added, except for the post_category. I wanted to add more than one category per product, and what I am using is an array.
What is probably the problem here?