2
votes

Hi i'm attempting to add custom taxonomy terms (hierarchical) to a page, via a form. I have a checkbox for each terms:

<input type="checkbox" name="term1" value="$taxonomy_term_id"/> 
<label for="themes" > $term_name </label>

<input type="checkbox" name="term2" value="$taxonomy_term_id2"/> 
<label for="themes" > $term_name2 </label>
[...]

On submit i'm using wp_set_object_terms function:

wp_set_object_terms($page_id,$_POST['term1'],$taxonomy_name,false);

but it only create a taxanomy term whose name is the value of $_POST['term1'] ( in admin panel, the page as no new taxonomy term checked, even the new term created ).

Any idea?

1

1 Answers

2
votes

This is it:

   $wpdb->insert( $wpdb->prefix .'term_relationships', array('object_id'=>$post_id, 'term_taxonomy_id'=>$_POST['term'], 'term_order'=>'0'));