# get_post_embed_html()

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

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

## Сигнатура

```php
get_post_embed_html( int $width, int $height, int|WP_Post|null $post = null ): string|false
```

## Описание

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

## Параметры

- `$width` `int` — обязательный. Ширина для ответа.
- `$height` `int` — обязательный. Высота для ответа.
- `$post` `int|WP_Post|null` — необязательный, по умолчанию `null`. ID или объект записи. Значение по умолчанию — глобальный $post.

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

`string|false`

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

Файл: `wp-includes/embed.php:490`

```php
function get_post_embed_html( $width, $height, $post = null ) {
	$post = get_post( $post );

	if ( ! $post ) {
		return false;
	}

	$embed_url = get_post_embed_url( $post );

	$secret     = wp_generate_password( 10, false );
	$embed_url .= "#?secret={$secret}";

	$output = sprintf(
		'<blockquote class="wp-embedded-content" data-secret="%1$s"><a href="%2$s">%3$s</a></blockquote>',
		esc_attr( $secret ),
		esc_url( get_permalink( $post ) ),
		get_the_title( $post )
	);

	$output .= sprintf(
		'<iframe sandbox="allow-scripts" security="restricted" src="%1$s" width="%2$d" height="%3$d" title="%4$s" data-secret="%5$s" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" class="wp-embedded-content"></iframe>',
		esc_url( $embed_url ),
		absint( $width ),
		absint( $height ),
		esc_attr(
			sprintf(
				/* translators: 1: Post title, 2: Site title. */
				__( '&#8220;%1$s&#8221; &#8212; %2$s' ),
				get_the_title( $post ),
				get_bloginfo( 'name' )
			)
		),
		esc_attr( $secret )
	);

	/*
	 * Note that the script must be placed after the <blockquote> and <iframe> due to a regexp parsing issue in
	 * `wp_filter_oembed_result()`. Because of the regex pattern starts with `|(<blockquote>.*?</blockquote>)?.*|`
	 * wherein the <blockquote> is marked as being optional, if it is not at the beginning of the string then the group
	 * will fail to match and everything will be matched by `.*` and not included in the group. This regex issue goes
	 * back to WordPress 4.4, so in order to not break older installs this script must come at the end.
	 */
	$js_path = '/js/wp-embed' . wp_scripts_get_suffix() . '.js';
	$output .= wp_get_inline_script_tag(
		trim( file_get_contents( ABSPATH . WPINC . $js_path ) ) . "\n//# sourceURL=" . esc_url_raw( includes_url( $js_path ) )
	);

	/**
	 * Filters the embed HTML output for a given post.
	 *
	 * @since 4.4.0
	 *
	 * @param string  $output The default iframe tag to display embedded content.
	 * @param WP_Post $post   Current post object.
	 * @param int     $width  Width of the response.
	 * @param int     $height Height of the response.
	 */
	return apply_filters( 'embed_html', $output, $post, $width, $height );
}
```

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

- 4.4.0 — Introduced.

## Связанные

Использует: [`wp_get_inline_script_tag`](https://chugunov.pro/api-wordpress/functions/wp_get_inline_script_tag/), [`wp_scripts_get_suffix`](https://chugunov.pro/api-wordpress/functions/wp_scripts_get_suffix/), [`get_post_embed_url`](https://chugunov.pro/api-wordpress/functions/get_post_embed_url/), [`esc_url_raw`](https://chugunov.pro/api-wordpress/functions/esc_url_raw/), [`wp_generate_password`](https://chugunov.pro/api-wordpress/functions/wp_generate_password/), [`includes_url`](https://chugunov.pro/api-wordpress/functions/includes_url/), [`get_the_title`](https://chugunov.pro/api-wordpress/functions/get_the_title/), [`__`](https://chugunov.pro/api-wordpress/functions/__/), [`esc_attr`](https://chugunov.pro/api-wordpress/functions/esc_attr/), [`esc_url`](https://chugunov.pro/api-wordpress/functions/esc_url/), [`get_bloginfo`](https://chugunov.pro/api-wordpress/functions/get_bloginfo/), [`absint`](https://chugunov.pro/api-wordpress/functions/absint/), [`get_permalink`](https://chugunov.pro/api-wordpress/functions/get_permalink/), [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/), [`get_post`](https://chugunov.pro/api-wordpress/functions/get_post/).
Используется в: [`print_embed_sharing_dialog`](https://chugunov.pro/api-wordpress/functions/print_embed_sharing_dialog/), [`get_oembed_response_data_rich`](https://chugunov.pro/api-wordpress/functions/get_oembed_response_data_rich/).

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