# _wp_build_title_and_description_for_taxonomy_block_template()

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

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

## Сигнатура

```php
_wp_build_title_and_description_for_taxonomy_block_template( string $taxonomy, string $slug, WP_Block_Template $template ): bool
```

## Описание

Изменяет исходный объект шаблона.

## Параметры

- `$taxonomy` `string` — обязательный. Идентификатор таксономии, например category.
- `$slug` `string` — обязательный. Слаг термина, например shoes.
- `$template` `WP_Block_Template` — обязательный. Шаблон, который нужно изменить, добавив вычисленные описание и название.

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

`bool`

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

Файл: `wp-includes/block-template-utils.php:762`

```php
function _wp_build_title_and_description_for_taxonomy_block_template( $taxonomy, $slug, WP_Block_Template $template ) {
	$taxonomy_object = get_taxonomy( $taxonomy );

	$default_args = array(
		'taxonomy'               => $taxonomy,
		'hide_empty'             => false,
		'update_term_meta_cache' => false,
	);

	$term_query = new WP_Term_Query();

	$args = array(
		'number' => 1,
		'slug'   => $slug,
	);
	$args = wp_parse_args( $args, $default_args );

	$terms_query = $term_query->query( $args );

	if ( empty( $terms_query ) ) {
		$template->title = sprintf(
			/* translators: Custom template title in the Site Editor, referencing a taxonomy term that was not found. 1: Taxonomy singular name, 2: Term slug. */
			__( 'Not found: %1$s (%2$s)' ),
			$taxonomy_object->labels->singular_name,
			$slug
		);
		return false;
	}

	$term_title = $terms_query[0]->name;

	$template->title = sprintf(
		/* translators: Custom template title in the Site Editor. 1: Taxonomy singular name, 2: Term title. */
		__( '%1$s: %2$s' ),
		$taxonomy_object->labels->singular_name,
		$term_title
	);

	$template->description = sprintf(
		/* translators: Custom template description in the Site Editor. %s: Term title. */
		__( 'Template for %s' ),
		$term_title
	);

	$term_query = new WP_Term_Query();

	$args = array(
		'number' => 2,
		'name'   => $term_title,
	);
	$args = wp_parse_args( $args, $default_args );

	$terms_with_same_title_query = $term_query->query( $args );

	if ( count( $terms_with_same_title_query ) > 1 ) {
		$template->title = sprintf(
			/* translators: Custom template title in the Site Editor. 1: Template title, 2: Term slug. */
			__( '%1$s (%2$s)' ),
			$template->title,
			$slug
		);
	}

	return true;
}
```

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

- 6.1.0 — Introduced.

## Связанные

Использует: `WP_Term_Query::__construct`, [`__`](https://chugunov.pro/api-wordpress/functions/__/), [`wp_parse_args`](https://chugunov.pro/api-wordpress/functions/wp_parse_args/), [`get_taxonomy`](https://chugunov.pro/api-wordpress/functions/get_taxonomy/).
Используется в: [`_build_block_template_result_from_post`](https://chugunov.pro/api-wordpress/functions/_build_block_template_result_from_post/).

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