I am implementing (trying) a front end posting system which shows taxonomy data in several dropdown select fields, each of the dropdowns is named by using the "name" $arg in wp_dropdown_categories.
<?php wp_dropdown_categories('taxonomy=location&hide_empty=0&orderby=name&order=asc&name=location') ?>
as you can see taxonomy is "location" and select name is "location".
I then add the variables for each of the taxonomy select dropdowns like so along with post_title, post_content etc:
$title = trim($_POST['wpuf_post_title']); $content = trim($_POST['wpuf_post_content']); $tags = wpuf_clean_tags($_POST['wpuf_post_tags']); $customcategory = trim($_POST['customcategory']); $cat = trim($_POST['cat']); $location = trim($_POST['location']); $sale_rental = trim($_POST['sale_rental']); $price = trim($_POST['price']);
and finally i add the extra info into an array ready to be sent by wp_insert_post, im quite stuck on whether i am doing the right thing by adding tax_input into the array like below as this is what i seem to be understanding from codex that i need to do.
'tax-input' => array( $location, $sale_rental, $price ),
so that it all ends up looking like this:
$my_post = array( 'post_title' => $title, 'post_content' => $content, 'post_status' => $post_status, 'post_author' => $userdata->ID, 'post_category' => array($_POST['cat']), 'post_type' => $customcategory, 'tags_input' => $tags, 'tax_input' => array( $location, $sale_rental, $price ), ); $post_id = wp_insert_post($my_post);
however when i submitted the new post, all the standard post data (and also my custom post type) goes in ok, but the taxonomies do not, im obviously doing something wrong, but what?