# get_categories()

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

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

## Сигнатура

```php
get_categories( string|array $args = '' ): array
```

## Описание

Если задать аргумент 'taxonomy' равным 'link_category', вместо этого будут возвращены рубрики ссылок.
Смотрите alsoget_terms(): тип аргументов, которые можно изменить.

## Параметры

- `$args` `string|array` — необязательный, по умолчанию `''`. Аргументы для извлечения рубрик. Дополнительные параметры смотрите в get_terms().
  
  taxonomy stringТаксономия, для которой извлекаются термины. По умолчанию 'category'.

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

`array`

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

Файл: `wp-includes/category.php:26`

```php
function get_categories( $args = '' ) {
	$defaults = array( 'taxonomy' => 'category' );
	$args     = wp_parse_args( $args, $defaults );

	/**
	 * Filters the taxonomy used to retrieve terms when calling get_categories().
	 *
	 * @since 2.7.0
	 *
	 * @param string $taxonomy Taxonomy to retrieve terms from.
	 * @param array  $args     An array of arguments. See get_terms().
	 */
	$args['taxonomy'] = apply_filters( 'get_categories_taxonomy', $args['taxonomy'], $args );

	// Back compat.
	if ( isset( $args['type'] ) && 'link' === $args['type'] ) {
		_deprecated_argument(
			__FUNCTION__,
			'3.0.0',
			sprintf(
				/* translators: 1: "type => link", 2: "taxonomy => link_category" */
				__( '%1$s is deprecated. Use %2$s instead.' ),
				'<code>type => link</code>',
				'<code>taxonomy => link_category</code>'
			)
		);
		$args['taxonomy'] = 'link_category';
	}

	$categories = get_terms( $args );

	if ( is_wp_error( $categories ) ) {
		$categories = array();
	} else {
		$categories = (array) $categories;
		foreach ( array_keys( $categories ) as $k ) {
			_make_cat_compat( $categories[ $k ] );
		}
	}

	return $categories;
}
```

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

- 2.1.0 — Introduced.

## Связанные

Использует: [`_make_cat_compat`](https://chugunov.pro/api-wordpress/functions/_make_cat_compat/), [`get_terms`](https://chugunov.pro/api-wordpress/functions/get_terms/), [`__`](https://chugunov.pro/api-wordpress/functions/__/), [`_deprecated_argument`](https://chugunov.pro/api-wordpress/functions/_deprecated_argument/), [`wp_parse_args`](https://chugunov.pro/api-wordpress/functions/wp_parse_args/), [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/), [`is_wp_error`](https://chugunov.pro/api-wordpress/functions/is_wp_error/).
Используется в: [`export_wp`](https://chugunov.pro/api-wordpress/functions/export_wp/), [`wp_dropdown_cats`](https://chugunov.pro/api-wordpress/functions/wp_dropdown_cats/), [`wp_list_categories`](https://chugunov.pro/api-wordpress/functions/wp_list_categories/), [`get_links_list`](https://chugunov.pro/api-wordpress/functions/get_links_list/), `wp_xmlrpc_server::mw_getCategories`, `wp_xmlrpc_server::mt_getCategoryList`, `wp_xmlrpc_server::wp_suggestCategories`.

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