wp_create_term()
Adds a new term to the database if it does not already exist.
Хуков нет.
Возвращает
Массив|WP_Error.
Использование
wp_create_term( $tag_name, $taxonomy );
- $tag_name(строка) (обязательный)
- The term name.
- $taxonomy(строка)
- The taxonomy within which to create the term.
По умолчанию:'post_tag'
Список изменений
| С версии 2.8.0 | Введена. |
Код wp_create_term() wp create term WP 7.0.3
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 );
}