# category_exists()

URL: https://chugunov.pro/api-wordpress/functions/category_exists/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 2.0.0.

## Сигнатура

```php
category_exists( int|string $cat_name, int $category_parent = null ): string|null
```

## Описание

См. alsoterm_exists()

## Параметры

- `$cat_name` `int|string` — обязательный. Имя рубрики.
- `$category_parent` `int` — необязательный, по умолчанию `null`. ID родительской категории.

## Возвращаемое значение

`string|null`

## Исходный код

Файл: `wp-admin/includes/taxonomy.php:24`

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

## История изменений

- 2.0.0 — Introduced.

## Связанные

Использует: [`term_exists`](https://chugunov.pro/api-wordpress/functions/term_exists/).
Используется в: [`wp_create_category`](https://chugunov.pro/api-wordpress/functions/wp_create_category/), [`wp_create_categories`](https://chugunov.pro/api-wordpress/functions/wp_create_categories/).

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/category_exists/
