wp_create_term

The timeline below displays how wordpress function wp_create_term has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Adds a new term to the database if it does not already exist.
 *
 * @since 2.8.0
 *
 * @param string $tag_name The term name.
 * @param string $taxonomy Optional. The taxonomy within which to create the term. Default 'post_tag'.
 * @return array|WP_Error
 */
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);
}

WordPress Version: 5.5

/**
 * Add a new term to the database if it does not already exist.
 *
 * @since 2.8.0
 *
 * @param string $tag_name The term name.
 * @param string $taxonomy Optional. The taxonomy within which to create the term. Default 'post_tag'.
 * @return array|WP_Error
 */
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);
}

WordPress Version: 5.3

/**
 * Add a new term to the database if it does not already exist.
 *
 * @since 2.8.0
 *
 * @param int|string $tag_name
 * @param string $taxonomy Optional. The taxonomy for which to retrieve terms. Default 'post_tag'.
 * @return array|WP_Error
 */
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);
}

WordPress Version: 4.2

/**
 * Add a new term to the database if it does not already exist.
 *
 * @since 2.8.0
 *
 * @param int|string $tag_name
 * @param string $taxonomy Optional. The taxonomy for which to retrieve terms. Default 'post_tag'.
 * @return array|WP_Error
 */
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);
}

WordPress Version: 4.1

/**
 * {@internal Missing Short Description}}
 *
 * @since 2.8.0
 *
 * @param int|string $tag_name
 * @return array|WP_Error
 */
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);
}

WordPress Version: 3.7

/**
 * {@internal Missing Short Description}}
 *
 * @since 2.8.0
 *
 * @param unknown_type $tag_name
 * @return unknown
 */
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);
}