# wp_get_post_content_block_attributes()

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

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

## Сигнатура

```php
wp_get_post_content_block_attributes(): array|null
```

## Описание

Получает атрибуты блока Post Content из текущего шаблона записи.

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

`array|null`

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

Файл: `wp-includes/block-editor.php:430`

```php
function wp_get_post_content_block_attributes() {
	global $post_ID;

	$is_block_theme = wp_is_block_theme();

	if ( ! $is_block_theme || ! $post_ID ) {
		return null;
	}

	$template_slug = get_page_template_slug( $post_ID );

	if ( ! $template_slug ) {
		$post_slug      = 'singular';
		$page_slug      = 'singular';
		$template_types = get_block_templates();

		foreach ( $template_types as $template_type ) {
			if ( 'page' === $template_type->slug ) {
				$page_slug = 'page';
			}
			if ( 'single' === $template_type->slug ) {
				$post_slug = 'single';
			}
		}

		$what_post_type = get_post_type( $post_ID );
		switch ( $what_post_type ) {
			case 'page':
				$template_slug = $page_slug;
				break;
			default:
				$template_slug = $post_slug;
				break;
		}
	}

	$current_template = get_block_templates( array( 'slug__in' => array( $template_slug ) ) );

	if ( ! empty( $current_template ) ) {
		$template_blocks    = parse_blocks( $current_template[0]->content );
		$post_content_block = wp_get_first_block( $template_blocks, 'core/post-content' );

		if ( isset( $post_content_block['attrs'] ) ) {
			return $post_content_block['attrs'];
		}
	}

	return null;
}
```

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

- 6.4.0 — Return null if there is no post content block.
- 6.3.0 — Introduced.

## Связанные

Использует: [`wp_get_first_block`](https://chugunov.pro/api-wordpress/functions/wp_get_first_block/), [`wp_is_block_theme`](https://chugunov.pro/api-wordpress/functions/wp_is_block_theme/), [`get_block_templates`](https://chugunov.pro/api-wordpress/functions/get_block_templates/), [`parse_blocks`](https://chugunov.pro/api-wordpress/functions/parse_blocks/), [`get_page_template_slug`](https://chugunov.pro/api-wordpress/functions/get_page_template_slug/), [`get_post_type`](https://chugunov.pro/api-wordpress/functions/get_post_type/).
Используется в: [`get_block_editor_settings`](https://chugunov.pro/api-wordpress/functions/get_block_editor_settings/).

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