category_exists()

最后更新于:2021-11-25 20:27:31

category_exists( int|string$cat_name, int$parent=null)

Check whether a category exists.

参数

$cat_name

(int|string) (Required) Category name.

$parent

(int) (Optional) ID of parent term.

Default value: null

响应

(mixed)

源文件

文件: gc-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;
}