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

Check whether a category exists.

Description Description

Top ↑

See also See also

Top ↑

Parameters Parameters


(int|string) (Required) Category name.


(int) (Optional) ID of parent term.

Default value: null

Top ↑

Return Return


Top ↑

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;

Top ↑

Changelog Changelog

Version Description
2.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

Top ↑

You must log in before being able to contribute a note or feedback.