A WordPress-centric search engine for devs and theme authors



wp_create_term ›

Since2.8.0
Deprecatedn/a
wp_create_term ( $tag_name, $taxonomy = 'post_tag' )
Parameters: (2)
  • (int|string) $tag_name
    Required: Yes
  • (string) $taxonomy Optional. The taxonomy for which to retrieve terms. Default 'post_tag'.
    Required: No
    Default: 'post_tag'
Returns:
  • (array|WP_Error)
Defined at:
Codex:

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



Source

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

	return wp_insert_term( $tag_name, $taxonomy );
}