wpseek.com
WordPress开发者和主题制作者的搜索引擎



category_exists › WordPress Function

Since2.0.0
已弃用n/a
category_exists ( $cat_name, $category_parent = null )
参数: (2)
  • (int|string) $cat_name Category name.
    Required: Yes
  • (int) $category_parent Optional. ID of parent category.
    Required: No
    默认: null
查看:
返回:
  • (string|null) Returns the category ID as a numeric string if the pairing exists, null if not.
定义在:
文档:

Checks whether a category exists.



源码

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