Adds a new term to the database if it does not already exist.
Parameters
-
$tag_namestring required -
The term name.
-
$taxonomystring optional -
The taxonomy within which to create the term. Default
'post_tag'.Default:
'post_tag'
Source
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 );
}
Changuelog
| Versionen | Description |
|---|---|
| 2.8.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.