# get_terms_to_edit()

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

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

## Сигнатура

```php
get_terms_to_edit( int $post_id, string $taxonomy = 'post_tag' ): string|false|WP_Error
```

## Описание

Получает список терминов, доступных для редактирования у заданной записи, через запятую.

## Параметры

- `$post_id` `int` — обязательный
- `$taxonomy` `string` — необязательный, по умолчанию `'post_tag'`. Таксономия, для которой нужно получить термины. Значение по умолчанию 'post_tag'.

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

`string|false|WP_Error`

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

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

```php
function get_terms_to_edit( $post_id, $taxonomy = 'post_tag' ) {
	$post_id = (int) $post_id;
	if ( ! $post_id ) {
		return false;
	}

	$terms = get_object_term_cache( $post_id, $taxonomy );
	if ( false === $terms ) {
		$terms = wp_get_object_terms( $post_id, $taxonomy );
		wp_cache_add( $post_id, wp_list_pluck( $terms, 'term_id' ), $taxonomy . '_relationships' );
	}

	if ( ! $terms ) {
		return false;
	}
	if ( is_wp_error( $terms ) ) {
		return $terms;
	}
	$term_names = array();
	foreach ( $terms as $term ) {
		$term_names[] = $term->name;
	}

	$terms_to_edit = esc_attr( implode( ',', $term_names ) );

	/**
	 * Filters the comma-separated list of terms available to edit.
	 *
	 * @since 2.8.0
	 *
	 * @see get_terms_to_edit()
	 *
	 * @param string $terms_to_edit A comma-separated list of term names.
	 * @param string $taxonomy      The taxonomy name for which to retrieve terms.
	 */
	$terms_to_edit = apply_filters( 'terms_to_edit', $terms_to_edit, $taxonomy );

	return $terms_to_edit;
}
```

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

- 2.8.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/), [`esc_attr`](https://chugunov.pro/api-wordpress/functions/esc_attr/), [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/), [`is_wp_error`](https://chugunov.pro/api-wordpress/functions/is_wp_error/).
Используется в: [`get_tags_to_edit`](https://chugunov.pro/api-wordpress/functions/get_tags_to_edit/), [`get_inline_data`](https://chugunov.pro/api-wordpress/functions/get_inline_data/), [`post_tags_meta_box`](https://chugunov.pro/api-wordpress/functions/post_tags_meta_box/).

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