Uses
Uses | Description |
---|---|
wp-includes/taxonomy.php: wp_insert_term() | Add a new term to the database. |
wp-includes/taxonomy.php: term_exists() | Determines whether a taxonomy term exists. |
Add a new term to the database if it does not already exist.
(string) (Required) The term name.
(string) (Optional) The taxonomy within which to create the term.
Default value: 'post_tag'
(array|WP_Error)
File: wp-admin/includes/taxonomy.php
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 ); }
Version | Description |
---|---|
2.8.0 | Introduced. |
© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_create_term