wp_create_term() – Add a new term to the database if it does not already exist.

You appear to be a bot. Output may be restricted

Description

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

Usage

$array|WP_Error = wp_create_term( $tag_name, $taxonomy );

Parameters

$tag_name
( string ) required – The term name.
$taxonomy
( string ) optional default: post_tag – Optional. The taxonomy within which to create the term. Default 'post_tag'.

Returns

array|WP_Error

Source

File name: wordpress/wp-admin/includes/taxonomy.php
Lines:

1 to 8 of 8
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 );
}
 

 View on GitHub View on Trac