# get_comment_text()

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

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

## Сигнатура

```php
get_comment_text( int|WP_Comment $comment_id, array $args = array() ): string
```

## Описание

[See also](#see-also)
- [Walker_Comment::comment()](https://developer.wordpress.org/reference/classes/Walker_Comment/comment/)

## Параметры

- `$comment_id` `int|WP_Comment` — необязательный. WP_Comment или ID комментария, для которого нужно получить текст.
  
  По умолчанию — текущий комментарий.
- `$args` `array` — необязательный, по умолчанию `array()`. Массив аргументов.

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

`string`

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

Файл: `wp-includes/comment-template.php:1029`

```php
function get_comment_text( $comment_id = 0, $args = array() ) {
	$comment = get_comment( $comment_id );

	$comment_text = $comment->comment_content;

	if ( is_comment_feed() && $comment->comment_parent ) {
		$parent = get_comment( $comment->comment_parent );
		if ( $parent ) {
			$parent_link = esc_url( get_comment_link( $parent ) );
			$name        = get_comment_author( $parent );

			$comment_text = sprintf(
				/* translators: %s: Comment link. */
				ent2ncr( __( 'In reply to %s.' ) ),
				'<a href="' . $parent_link . '">' . $name . '</a>'
			) . "\n\n" . $comment_text;
		}
	}

	/**
	 * Filters the text of a comment.
	 *
	 * @since 1.5.0
	 *
	 * @see Walker_Comment::comment()
	 *
	 * @param string     $comment_text Text of the comment.
	 * @param WP_Comment $comment      The comment object.
	 * @param array      $args         An array of arguments.
	 */
	return apply_filters( 'get_comment_text', $comment_text, $comment, $args );
}
```

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

- 5.4.0 — Added ‘In reply to %s.’ prefix to child comments in comments feed.
- 4.4.0 — Added the ability for $comment_id to also accept a WP_Comment object.
- 1.5.0 — Introduced.

## Связанные

Использует: [`ent2ncr`](https://chugunov.pro/api-wordpress/functions/ent2ncr/), [`is_comment_feed`](https://chugunov.pro/api-wordpress/functions/is_comment_feed/), [`get_comment_link`](https://chugunov.pro/api-wordpress/functions/get_comment_link/), [`get_comment_author`](https://chugunov.pro/api-wordpress/functions/get_comment_author/), [`__`](https://chugunov.pro/api-wordpress/functions/__/), [`esc_url`](https://chugunov.pro/api-wordpress/functions/esc_url/), [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/), [`get_comment`](https://chugunov.pro/api-wordpress/functions/get_comment/).
Используется в: [`wp_comments_personal_data_exporter`](https://chugunov.pro/api-wordpress/functions/wp_comments_personal_data_exporter/), [`comment_text_rss`](https://chugunov.pro/api-wordpress/functions/comment_text_rss/), [`comment_text`](https://chugunov.pro/api-wordpress/functions/comment_text/).

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