# get_category_children()

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

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

> Устаревший элемент. Помечен устаревшим с версии 2.8.0.

## Сигнатура

```php
get_category_children( int $id, string $before = '/', string $after = '', array $visited = array() ): string
```

## Описание

См. alsoget_term_children()

## Параметры

- `$id` `int` — обязательный. ID категории, для которой нужно получить дочерние элементы.
- `$before` `string` — необязательный, по умолчанию `'/'`. Добавляется перед ID термина категории. Значение по умолчанию: '/'.
- `$after` `string` — необязательный, по умолчанию `''`. Добавляется после ID термина категории.
- `$visited` `array` — необязательный, по умолчанию `array()`. ID терминов категорий, которые уже были добавлены.

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

`string`

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

Файл: `wp-includes/deprecated.php:1278`

```php
function get_category_children( $id, $before = '/', $after = '', $visited = array() ) {
	_deprecated_function( __FUNCTION__, '2.8.0', 'get_term_children()' );
	if ( 0 == $id )
		return '';

	$chain = '';
	/** TODO: Consult hierarchy */
	$cat_ids = get_all_category_ids();
	foreach ( (array) $cat_ids as $cat_id ) {
		if ( $cat_id == $id )
			continue;

		$category = get_category( $cat_id );
		if ( is_wp_error( $category ) )
			return $category;
		if ( $category->parent == $id && !in_array( $category->term_id, $visited ) ) {
			$visited[] = $category->term_id;
			$chain .= $before.$category->term_id.$after;
			$chain .= get_category_children( $category->term_id, $before, $after );
		}
	}
	return $chain;
}
```

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

- 2.8.0 — Deprecated. Use get_term_children()
- 1.2.0 — Introduced.

## Связанные

Использует: [`get_category_children`](https://chugunov.pro/api-wordpress/functions/get_category_children/), [`get_all_category_ids`](https://chugunov.pro/api-wordpress/functions/get_all_category_ids/), [`get_category`](https://chugunov.pro/api-wordpress/functions/get_category/), [`_deprecated_function`](https://chugunov.pro/api-wordpress/functions/_deprecated_function/), [`is_wp_error`](https://chugunov.pro/api-wordpress/functions/is_wp_error/).
Используется в: [`get_category_children`](https://chugunov.pro/api-wordpress/functions/get_category_children/).

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