# get_the_terms()

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

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

## Сигнатура

```php
get_the_terms( int|WP_Post $post, string $taxonomy ): WP_Term[]|false|WP_Error
```

## Описание

Получает термины таксономии, прикреплённые к записи.

## Параметры

- `$post` `int|WP_Post` — обязательный. Идентификатор или объект записи.
- `$taxonomy` `string` — обязательный. Имя таксономии.

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

`WP_Term[]|false|WP_Error` — WP_Term WP_Error

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

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

```php
function get_the_terms( $post, $taxonomy ) {
	$post = get_post( $post );

	if ( ! $post ) {
		return false;
	}

	$terms = get_object_term_cache( $post->ID, $taxonomy );

	if ( false === $terms ) {
		$terms = wp_get_object_terms( $post->ID, $taxonomy );
		if ( ! is_wp_error( $terms ) ) {
			$term_ids = wp_list_pluck( $terms, 'term_id' );
			wp_cache_add( $post->ID, $term_ids, $taxonomy . '_relationships' );
		}
	}

	/**
	 * Filters the list of terms attached to the given post.
	 *
	 * @since 3.1.0
	 *
	 * @param WP_Term[]|WP_Error $terms    Array of attached terms, or WP_Error on failure.
	 * @param int                $post_id  Post ID.
	 * @param string             $taxonomy Name of the taxonomy.
	 */
	$terms = apply_filters( 'get_the_terms', $terms, $post->ID, $taxonomy );

	if ( empty( $terms ) ) {
		return false;
	}

	return $terms;
}
```

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

- 2.5.0 — Introduced.

## Связанные

Использует: [`wp_cache_add`](https://chugunov.pro/api-wordpress/functions/wp_cache_add/), [`wp_list_pluck`](https://chugunov.pro/api-wordpress/functions/wp_list_pluck/), [`get_object_term_cache`](https://chugunov.pro/api-wordpress/functions/get_object_term_cache/), [`wp_get_object_terms`](https://chugunov.pro/api-wordpress/functions/wp_get_object_terms/), [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/), [`get_post`](https://chugunov.pro/api-wordpress/functions/get_post/), [`is_wp_error`](https://chugunov.pro/api-wordpress/functions/is_wp_error/).
Используется в: [`inject_ignored_hooked_blocks_metadata_attributes`](https://chugunov.pro/api-wordpress/functions/inject_ignored_hooked_blocks_metadata_attributes/), `WP_REST_Menu_Items_Controller::prepare_item_for_response`, [`wp_set_unique_slug_on_create_template_part`](https://chugunov.pro/api-wordpress/functions/wp_set_unique_slug_on_create_template_part/), [`_build_block_template_result_from_post`](https://chugunov.pro/api-wordpress/functions/_build_block_template_result_from_post/), [`wp_filter_wp_template_unique_post_slug`](https://chugunov.pro/api-wordpress/functions/wp_filter_wp_template_unique_post_slug/), `WP_REST_Posts_Controller::prepare_item_for_response`, `WP_Posts_List_Table::column_default`, `WP_Media_List_Table::column_default`, [`get_the_term_list`](https://chugunov.pro/api-wordpress/functions/get_the_term_list/), [`get_the_tags`](https://chugunov.pro/api-wordpress/functions/get_the_tags/), [`get_the_category`](https://chugunov.pro/api-wordpress/functions/get_the_category/), [`get_post_class`](https://chugunov.pro/api-wordpress/functions/get_post_class/), `WP_Post::__get`, [`wp_publish_post`](https://chugunov.pro/api-wordpress/functions/wp_publish_post/), [`wp_update_post`](https://chugunov.pro/api-wordpress/functions/wp_update_post/), [`get_post_format`](https://chugunov.pro/api-wordpress/functions/get_post_format/).

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