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;
}