I have been through many posts on this subject and just can't seem to wrap my head around what I need to do.
I have a form where users can submit a post to a custom post type from the from end. I want to incorporate a dropdown menu where the users can select from a custom taxonomy that I have created. I need to save the value selected when the form is submitted.
The Form:
<fieldset class="jobcategorydropdown">
<label for="jobcatdd"> Job Category </label>
<?php wp_dropdown_categories( 'taxonomy=jobcats&hide_empty=0&name=ddjobcats' ); ?>
</fieldset>
Register Taxonomy:
register_taxonomy('jobcats', 'job_listing', array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'topic' ),
));
Make new post:
function make_job_post() {
$type = 'job_listing';
$jobcatvalue = $_POST['jobcats'];
$post_information = array(
'post_title' => wp_strip_all_tags( $_POST['postTitle'] ),
'post_content' => $_POST['postContent'],
'post_type' => $type,
'post_status' => 'publish',
'tax_input' => array($jobcatvalue)
);
$pid = wp_insert_post($post_information);
wp_set_object_terms($pid, $jobcatvalue,'jobcats');
}
Am I missing something? Any help would be greatly appreciated!