您不能使用wp_set_post_terms()
设置术语描述,但可以使用wp_insert_term()
创建术语并设置描述(以及其他详细信息),然后将术语ID传递给wp_set_post_terms()
.
一个术语的工作示例:
$taxonomy = \'category\';
$term_name = \'Foo Bar\';
// First we create the term (if it doesn\'t already exist).
if ( ! $term = term_exists( $term_name, $taxonomy ) ) {
$term = wp_insert_term( $term_name, $taxonomy, array(
\'description\' => \'Test category\',
) );
}
// Now assign the term to the post (here the post ID is 1).
if ( $term && ! is_wp_error( $term ) ) {
wp_set_post_terms( 1, $term[\'term_id\'], $taxonomy );
}