Codex tools: Log in
Contents |
Set terms for a post. Uses wp_set_object_terms().
<?php wp_set_post_terms( $post_ID, $terms, $taxonomy, $append ) ?>
Hierarchical terms must always pass the id rather than the term name to avoid confusion where there may be another child with the same name.
To get the term id you can use: $term_id = term_exists($term, $taxonomy, $parent );
You may also need to pass by reference. wp_set_post_terms( $post_id, $term, &$taxonomy );
Since: 2.8.0
wp_set_post_terms() is located in wp-includes/post.php.
Terms: is_term(), term_exists(), get_objects_in_term(), get_term(), get_term_by(), get_term_children(), get_term_link(), get_terms(), get_the_terms(), get_the_term_list(), has_term(), sanitize term(), wp_get_object_terms(), wp_set_object_terms(), wp_get_post_terms(), wp_set_post_terms()