# get_the_content()

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

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

## Сигнатура

```php
get_the_content( string $more_link_text = null, bool $strip_teaser = false, WP_Post|object|int $post = null ): string
```

## Описание

Получает содержимое записи.

## Параметры

- `$more_link_text` `string` — необязательный, по умолчанию `null`. Содержимое для случая, когда есть продолжение текста.
- `$strip_teaser` `bool` — необязательный, по умолчанию `false`. Удалить содержимое анонса перед текстом продолжения.
- `$post` `WP_Post|object|int` — необязательный, по умолчанию `null`. Экземпляр WP_Post либо ID/объект записи.

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

`string`

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

Файл: `wp-includes/post-template.php:279`

```php
function get_the_content( $more_link_text = null, $strip_teaser = false, $post = null ) {
	global $page, $more, $preview, $pages, $multipage;

	$_post = get_post( $post );

	if ( ! ( $_post instanceof WP_Post ) ) {
		return '';
	}

	/*
	 * Use the globals if the $post parameter was not specified,
	 * but only after they have been set up in setup_postdata().
	 */
	if ( null === $post && did_action( 'the_post' ) ) {
		$elements = compact( 'page', 'more', 'preview', 'pages', 'multipage' );
	} else {
		$elements = generate_postdata( $_post );
	}

	if ( null === $more_link_text ) {
		$more_link_text = sprintf(
			'<span aria-label="%1$s">%2$s</span>',
			sprintf(
				/* translators: %s: Post title. */
				__( 'Continue reading %s' ),
				the_title_attribute(
					array(
						'echo' => false,
						'post' => $_post,
					)
				)
			),
			__( '(more&hellip;)' )
		);
	}

	$output     = '';
	$has_teaser = false;

	// If post password required and it doesn't match the cookie.
	if ( post_password_required( $_post ) ) {
		return get_the_password_form( $_post );
	}

	// If the requested page doesn't exist.
	if ( $elements['page'] > count( $elements['pages'] ) ) {
		// Give them the highest numbered page that DOES exist.
		$elements['page'] = count( $elements['pages'] );
	}

	$page_no = $elements['page'];
	$content = $elements['pages'][ $page_no - 1 ];
	if ( preg_match( '/<!--more(.*?)?-->/', $content, $matches ) ) {
		if ( has_block( 'more', $content ) ) {
			// Remove the core/more block delimiters. They will be left over after $content is split up.
			$content = preg_replace( '/<!-- \/?wp:more(.*?) -->/', '', $content );
		}

		$content = explode( $matches[0], $content, 2 );

		if ( ! empty( $matches[1] ) && ! empty( $more_link_text ) ) {
			$more_link_text = strip_tags( wp_kses_no_null( trim( $matches[1] ) ) );
		}

		$has_teaser = true;
	} else {
		$content = array( $content );
	}

	if ( str_contains( $_post->post_content, '<!--noteaser-->' )
		&& ( ! $elements['multipage'] || 1 === $elements['page'] )
	) {
		$strip_teaser = true;
	}

	$teaser = $content[0];

	if ( $elements['more'] && $strip_teaser && $has_teaser ) {
		$teaser = '';
	}

	$output .= $teaser;

	if ( count( $content ) > 1 ) {
		if ( $elements['more'] ) {
			$output .= '<span id="more-' . $_post->ID . '"></span>' . $content[1];
		} else {
			if ( ! empty( $more_link_text ) ) {

				/**
				 * Filters the Read More link text.
				 *
				 * @since 2.8.0
				 *
				 * @param string $more_link_element Read More link element.
				 * @param string $more_link_text    Read More text.
				 */
				$output .= apply_filters( 'the_content_more_link', ' <a href="' . get_permalink( $_post ) . "#more-{$_post->ID}\" class=\"more-link\">$more_link_text</a>", $more_link_text );
			}
			$output = force_balance_tags( $output );
		}
	}

	return $output;
}
```

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

- 5.2.0 — Added the $post parameter.
- 0.71 — Introduced.

## Связанные

Использует: [`generate_postdata`](https://chugunov.pro/api-wordpress/functions/generate_postdata/), [`has_block`](https://chugunov.pro/api-wordpress/functions/has_block/), [`force_balance_tags`](https://chugunov.pro/api-wordpress/functions/force_balance_tags/), [`wp_kses_no_null`](https://chugunov.pro/api-wordpress/functions/wp_kses_no_null/), [`did_action`](https://chugunov.pro/api-wordpress/functions/did_action/), [`get_the_password_form`](https://chugunov.pro/api-wordpress/functions/get_the_password_form/), [`post_password_required`](https://chugunov.pro/api-wordpress/functions/post_password_required/), [`the_title_attribute`](https://chugunov.pro/api-wordpress/functions/the_title_attribute/), [`__`](https://chugunov.pro/api-wordpress/functions/__/), [`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/).
Используется в: [`wp_trim_excerpt`](https://chugunov.pro/api-wordpress/functions/wp_trim_excerpt/), [`the_content_rss`](https://chugunov.pro/api-wordpress/functions/the_content_rss/), [`get_the_content_feed`](https://chugunov.pro/api-wordpress/functions/get_the_content_feed/), [`the_content`](https://chugunov.pro/api-wordpress/functions/the_content/).

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