category_exists() – Check whether a category exists.

You appear to be a bot. Output may be restricted

Description

Checks whether a category exists.

Usage

$string|null = category_exists( $cat_name, $category_parent );

Parameters

$cat_name
( int|string ) required – Category name.
$category_parent
( int ) optional – Optional. ID of parent category.

Returns

string|null Returns the category ID as a numeric string if the pairing exists, null if not.

Source

File name: wordpress/wp-admin/includes/taxonomy.php
Lines:

1 to 7 of 7
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;
}
 

 View on GitHub View on Trac