category_exists

Advertisement

Summery Summery

Check whether a category exists.

Syntax Syntax

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

Parameters Parameters

$cat_name

(Required) Category name.

$parent

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

Advertisement

Changelog Changelog

Changelog
Version Description
2.0.0 Introduced.

See also See also

Advertisement

Leave a Reply