Unable to use custom taxonomy with front end post form

Take a look at the Codex back for wp_insert_post. I’ve not checked, but I do not think this is correct:

 'post_category' =>  array($_POST['booru_locations']),  // Usable for custom taxonomies too

The array passed to wp_insert_post, however can contain a tax_input key, whose value is an array of arrays:

 'tax_input' =>array( 'booru_locations' => array( 'term', 'term2', 'term3' ) )

The value for ‘booru_locations’ must an array of strings (for term slugs) or integers (for term IDs). If you are using term IDs you must make sure they are integers by casting them as such.


So $_POST['booru_locations'] contains a term ID for the taxonomy ‘booru_locations’. First, make sure its an integer (not a string representation of) and create an array of IDs (in this case there will be only one):

 $location_id = intval($_POST['booru_locations']);
 $locations = (!empty($location_id) ? array($location_id) : array());

So $locations an array of integers (term IDs). We can then add this to the $new_post array

// ADD THE FORM INPUT TO $new_post ARRAY
$new_post = array(
'post_title'    =>  $title,
'post_content'  =>  $description,
'post_image'    => $newupload,
'post_status'   =>  'publish',  
'post_type' =>  'booru_directory',
'tax_input' =>  array('booru_locations'=>$locations),
);