Hi my good friends I need your help better than losing my mind, first I have to thank "Stephen Harris" for his good article ,
-second: After a lot of searching I still don't know how to inject a custom taxonomy to a custom post type Here is my code:
$post_id = wp_insert_post(array(
'post_author' => $user_id,
'post_title' => $post_title,
'post_content' => $post_content,
'post_category' => array($_POST['cat']), // Usable for custom taxonomies too
'tax_input' => array('offer' => $terms),
'tags_input' => array($tags),
'post_type' => 'classified',
'post_status' => 'publish'
));
update_post_meta($post_id,'$term->term_id',$taxonomy,true);
and
<?php
//Set up the taxonomy object and get terms
$taxonomy = 'offer';
$tax = get_taxonomy($taxonomy); //This is the taxonomy object
$name = 'tax_input[' . $taxonomy . ']';
$terms = get_terms($taxonomy, array('hide_empty' => 0));
$postterms = get_the_terms($post->ID, $taxonomy);
$current = ($postterms ? array_pop($postterms) : false);
$current = ($current ? $current->term_id : 0);
?>
<!-- Display taxonomy terms -->
<div id="<?php echo $taxonomy; ?>-all" class="tabs-panel">
<ul id="<?php echo $taxonomy; ?>checklist" class="list:<?php echo $taxonomy ?> categorychecklist form-no-clear">
<?php
foreach ($terms as $term) {
$id = $taxonomy . '-' . $term->term_id;
echo "<li id='$id'><label class='selectit'>";
echo "<input type='radio' id='in-$id' name='{$name}'" . checked($current, $term->term_id, false) . "value='$term->term_id' />$term->name<br />";
echo "</label></li>";
}
?>
</ul>
</div>
What do I miss, Thanks for the help.