Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

enter image description here

I have displayed the custom taxonomies in the drop down as you see in the red box i want to ask that how can i submit them with the post .I can't figure it out.`

// Do some minor form validation to make sure there is content
if (isset ($_POST['title'])) {
    $title =  $_POST['title'];
} else {
    echo 'Please enter the wine name';
}

// ADD THE FORM INPUT TO $new_post ARRAY
$new_post = array(
'post_title'    =>  $title,
'tax_input' => array(
    'industries' =>  $_REQUEST['taxonomy_id'] ),
'post_status'   =>  'publish',           // Choose: publish, preview, future, draft, etc.
'post_type' =>  'websites'  //'post',page' or use a custom post type if you want to
);

//SAVE THE POST
$pid = wp_insert_post($new_post);

//SET OUR TAGS UP PROPERLY

//REDIRECT TO THE NEW POST ON SAVE
$link = get_permalink( $pid );
wp_redirect( $link );

} // END THE IF STATEMENT THAT STARTED THE WHOLE FORM

//POST THE POST YO
do_action('wp_insert_post', 'wp_insert_post');?>`

the form

enter code here
share|improve this question
    
Could you share some more info/code that you are using? Are you using wp_insert_post(); ? –  jzatt Dec 4 '12 at 7:53
    
yes i am using wp_inser_post(); –  FAWAZ Dec 4 '12 at 8:15
    
this is the form <div class="catBox"> <a href="#" class="show">Select Industry</a> <div class="slidingDiv"> <?php $industryterms = get_terms('industries'); foreach ( $industryterms as $industryterm ) { echo '<div class="clearfix"><input type="checkbox" />'."<label>".$industryterm->name."</label>".'</div>'; }?> –  FAWAZ Dec 4 '12 at 8:17
add comment

1 Answer

up vote 2 down vote accepted

Update your form to include the term-id, instead of just <input type="checkbox" /> use <input type="checkbox" name="taxonomy_id[]" value="'. $industryterm->term_id .'" />. That way you are actually sending along some values, in this case the term id.

And in the args for wp_insert_post() make sure to include something like this:

'tax_input' => array(
    'industries' => $_REQUEST['taxonomy_id']
)
share|improve this answer
    
and what will be the label –  FAWAZ Dec 4 '12 at 8:49
    
i am just getting word array in the taxonomy –  FAWAZ Dec 4 '12 at 8:51
1  
Updated the answer, removed the "array( )" part. This should do it. Not sure what you mean about the label part? You already have a label in the form. –  jzatt Dec 4 '12 at 9:00
    
now i am getting .$industryterm->id. in the taxonomy –  FAWAZ Dec 4 '12 at 9:14
1  
Great, don't forget to mark the question as solved! –  jzatt Dec 4 '12 at 12:05
show 7 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.