A WordPress-centric search engine for devs and theme authors



category_exists ›

Since2.0.0
Deprecatedn/a
category_exists ( $cat_name, $parent = null )
Parameters: (2)
  • (int|string) $cat_name Category name.
    Required: Yes
  • (int) $parent Optional. ID of parent term.
    Required: No
    Default: null
See:
Returns:
  • (mixed)
Defined at:
Codex:

Check whether a category exists.



Source

function category_exists( $cat_name, $parent = null ) {
	$id = term_exists( $cat_name, 'category', $parent );
	if ( is_array( $id ) ) {
		$id = $id['term_id'];
	}
	return $id;
}