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



wp_create_term ›

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

Add 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 );
}