insert category from form in a post
You need to create the category first, then add it to the post: $my_post = array(); $my_post[‘post_author’] = $userid; $my_post[‘post_title’] = $name; $my_post[‘post_name’] = str_replace(‘ ‘, ‘-‘, $name); $cat_id = wp_create_category($_POST[‘postcats’], 0); // we create the category and we get the ID, the 0 is for no parent category $my_post[‘post_category’] = array($cat_id);//this value is an … Read more