category_exists( int|string $cat_name, int $parent = null )
Check whether a category exists.
Contents
Description Description
See also See also
Parameters Parameters
- $cat_name
-
(int|string) (Required) Category name.
- $parent
-
(int) (Optional) ID of parent term.
Default value: null
Return Return
(mixed)
Source 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; }
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
2.0.0 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
Beware this function is only available in the wp-admin and will throw an error if used in the front end of your site. Use term_exists instead.