WordPress: add custom taxonomy to a page programmatically

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:

Read More
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?

Related posts

Leave a Reply

1 comment