category_exists

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

WordPress Version: 6.1

/**
 * WordPress Taxonomy Administration API.
 *
 * @package WordPress
 * @subpackage Administration
 */
//
// Category.
//
/**
 * Checks whether a category exists.
 *
 * @since 2.0.0
 *
 * @see term_exists()
 *
 * @param int|string $cat_name        Category name.
 * @param int        $category_parent Optional. ID of parent category.
 * @return string|null Returns the category ID as a numeric string if the pairing exists, null if not.
 */
function category_exists($cat_name, $category_parent = null)
{
    $id = term_exists($cat_name, 'category', $category_parent);
    if (is_array($id)) {
        $id = $id['term_id'];
    }
    return $id;
}

WordPress Version: 5.9

/**
 * WordPress Taxonomy Administration API.
 *
 * @package WordPress
 * @subpackage Administration
 */
//
// Category.
//
/**
 * Check whether a category exists.
 *
 * @since 2.0.0
 *
 * @see term_exists()
 *
 * @param int|string $cat_name Category name.
 * @param int        $parent   Optional. ID of parent term.
 * @return string|null Returns the category ID as a numeric string if the pairing exists, null if not.
 */
function category_exists($cat_name, $parent = null)
{
    $id = term_exists($cat_name, 'category', $parent);
    if (is_array($id)) {
        $id = $id['term_id'];
    }
    return $id;
}

WordPress Version: 5.4

/**
 * WordPress Taxonomy Administration API.
 *
 * @package WordPress
 * @subpackage Administration
 */
//
// Category.
//
/**
 * Check whether a category exists.
 *
 * @since 2.0.0
 *
 * @see term_exists()
 *
 * @param int|string $cat_name Category name.
 * @param int        $parent   Optional. ID of parent term.
 * @return mixed
 */
function category_exists($cat_name, $parent = null)
{
    $id = term_exists($cat_name, 'category', $parent);
    if (is_array($id)) {
        $id = $id['term_id'];
    }
    return $id;
}

WordPress Version: 1.1

/**
 * WordPress Taxonomy Administration API.
 *
 * @package WordPress
 * @subpackage Administration
 */
//
// Category
//
/**
 * Check whether a category exists.
 *
 * @since 2.0.0
 *
 * @see term_exists()
 *
 * @param int|string $cat_name Category name.
 * @param int        $parent   Optional. ID of parent term.
 * @return mixed
 */
function category_exists($cat_name, $parent = null)
{
    $id = term_exists($cat_name, 'category', $parent);
    if (is_array($id)) {
        $id = $id['term_id'];
    }
    return $id;
}

WordPress Version: 4.1

/**
 * WordPress Taxonomy Administration API.
 *
 * @package WordPress
 * @subpackage Administration
 */
//
// Category
//
/**
 * {@internal Missing Short Description}}
 *
 * @since 2.0.0
 *
 * @param int|string $cat_name
 * @return int
 */
function category_exists($cat_name, $parent = 0)
{
    $id = term_exists($cat_name, 'category', $parent);
    if (is_array($id)) {
        $id = $id['term_id'];
    }
    return $id;
}

WordPress Version: 3.7

/**
 * WordPress Taxonomy Administration API.
 *
 * @package WordPress
 * @subpackage Administration
 */
//
// Category
//
/**
 * {@internal Missing Short Description}}
 *
 * @since 2.0.0
 *
 * @param unknown_type $cat_name
 * @return unknown
 */
function category_exists($cat_name, $parent = 0)
{
    $id = term_exists($cat_name, 'category', $parent);
    if (is_array($id)) {
        $id = $id['term_id'];
    }
    return $id;
}