category_exists( int|string $cat_name, int $category_parent = null )
Checks whether a category exists.
Description
See also
Parameters
- $cat_name
-
(Required) Category name.
- $category_parent
-
(Optional) ID of parent category.
Default value: null
Return
(string|null) Returns the category ID as a numeric string if the pairing exists, null if not.
Source
File: wp-admin/includes/taxonomy.php
function category_exists( $cat_name, $parent = null ) {
$id = term_exists($cat_name, 'category', $parent);
if ( is_array($id) )
$id = $id['term_id'];
return $id;
}
Changelog
Version | Description |
---|---|
2.0.0 | Introduced. |