wpseek.com
WordPress开发者和主题制作者的搜索引擎



wp_create_term › WordPress Function

Since2.8.0
已弃用n/a
wp_create_term ( $tag_name, $taxonomy = 'post_tag' )
参数: (2)
  • (string) $tag_name The term name.
    Required: Yes
  • (string) $taxonomy Optional. The taxonomy within which to create the term. Default 'post_tag'.
    Required: No
    默认: 'post_tag'
返回:
  • (array|WP_Error)
定义在:
文档:

Adds a new term to the database if it does not already exist.



源码

function wp_create_term( $tag_name, $taxonomy = 'post_tag' ) {
	$id = term_exists( $tag_name, $taxonomy );
	if ( $id ) {
		return $id;
	}

	return wp_insert_term( $tag_name, $taxonomy );
}