# get_the_category_rss()

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

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

## Сигнатура

```php
get_the_category_rss( string $type = null ): string
```

## Описание

Все рубрики текущей записи в цикле ленты будут извлечены и снабжены разметкой ленты, чтобы их можно было легко добавить в ленты RSS2, Atom или RSS1 и RSS0.91 RDF.

## Параметры

- `$type` `string` — необязательный, по умолчанию `null`. По умолчанию — тип, возвращаемый get_default_feed().

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

`string`

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

Файл: `wp-includes/feed.php:381`

```php
function get_the_category_rss( $type = null ) {
	if ( empty( $type ) ) {
		$type = get_default_feed();
	}
	$categories = get_the_category();
	$tags       = get_the_tags();
	$the_list   = '';
	$cat_names  = array();

	$filter = 'rss';
	if ( 'atom' === $type ) {
		$filter = 'raw';
	}

	if ( ! empty( $categories ) ) {
		foreach ( (array) $categories as $category ) {
			$cat_names[] = sanitize_term_field( 'name', $category->name, $category->term_id, 'category', $filter );
		}
	}

	if ( ! empty( $tags ) ) {
		foreach ( (array) $tags as $tag ) {
			$cat_names[] = sanitize_term_field( 'name', $tag->name, $tag->term_id, 'post_tag', $filter );
		}
	}

	$cat_names = array_unique( $cat_names );

	foreach ( $cat_names as $cat_name ) {
		if ( 'rdf' === $type ) {
			$the_list .= "\t\t<dc:subject><![CDATA[$cat_name]]></dc:subject>\n";
		} elseif ( 'atom' === $type ) {
			$the_list .= sprintf( '<category scheme="%1$s" term="%2$s" />', esc_attr( get_bloginfo_rss( 'url' ) ), esc_attr( $cat_name ) );
		} else {
			$the_list .= "\t\t<category><![CDATA[" . html_entity_decode( $cat_name, ENT_COMPAT, get_option( 'blog_charset' ) ) . "]]></category>\n";
		}
	}

	/**
	 * Filters all of the post categories for display in a feed.
	 *
	 * @since 1.2.0
	 *
	 * @param string $the_list All of the RSS post categories.
	 * @param string $type     Type of feed. Possible values include 'rss2', 'atom'.
	 *                         Default 'rss2'.
	 */
	return apply_filters( 'the_category_rss', $the_list, $type );
}
```

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

- 2.1.0 — Introduced.

## Связанные

Использует: [`get_the_tags`](https://chugunov.pro/api-wordpress/functions/get_the_tags/), [`get_the_category`](https://chugunov.pro/api-wordpress/functions/get_the_category/), [`sanitize_term_field`](https://chugunov.pro/api-wordpress/functions/sanitize_term_field/), [`get_default_feed`](https://chugunov.pro/api-wordpress/functions/get_default_feed/), [`get_bloginfo_rss`](https://chugunov.pro/api-wordpress/functions/get_bloginfo_rss/), [`esc_attr`](https://chugunov.pro/api-wordpress/functions/esc_attr/), [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/), [`get_option`](https://chugunov.pro/api-wordpress/functions/get_option/).
Используется в: [`the_category_rss`](https://chugunov.pro/api-wordpress/functions/the_category_rss/).

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