# get_the_title()

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

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

## Сигнатура

```php
get_the_title( int|WP_Post $post ): string
```

## Описание

Если запись защищена паролем, а посетитель не является администратором, перед заголовком записи будет вставлено «Protected». Если запись приватная, перед заголовком записи будет вставлено «Private».

## Параметры

- `$post` `int|WP_Post` — необязательный. ID записи или объект WP_Post. По умолчанию — глобальная переменная $post.

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

`string`

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

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

```php
function get_the_title( $post = 0 ) {
	$post = get_post( $post );

	$post_title = $post->post_title ?? '';
	$post_id    = $post->ID ?? 0;

	if ( ! is_admin() ) {
		if ( ! empty( $post->post_password ) ) {

			/* translators: %s: Protected post title. */
			$prepend = __( 'Protected: %s' );

			/**
			 * Filters the text prepended to the post title for protected posts.
			 *
			 * The filter is only applied on the front end.
			 *
			 * @since 2.8.0
			 *
			 * @param string  $prepend Text displayed before the post title.
			 *                         Default 'Protected: %s'.
			 * @param WP_Post $post    Current post object.
			 */
			$protected_title_format = apply_filters( 'protected_title_format', $prepend, $post );

			$post_title = sprintf( $protected_title_format, $post_title );
		} elseif ( isset( $post->post_status ) && 'private' === $post->post_status ) {

			/* translators: %s: Private post title. */
			$prepend = __( 'Private: %s' );

			/**
			 * Filters the text prepended to the post title of private posts.
			 *
			 * The filter is only applied on the front end.
			 *
			 * @since 2.8.0
			 *
			 * @param string  $prepend Text displayed before the post title.
			 *                         Default 'Private: %s'.
			 * @param WP_Post $post    Current post object.
			 */
			$private_title_format = apply_filters( 'private_title_format', $prepend, $post );

			$post_title = sprintf( $private_title_format, $post_title );
		}
	}

	/**
	 * Filters the post title.
	 *
	 * @since 0.71
	 *
	 * @param string $post_title The post title.
	 * @param int    $post_id    The post ID.
	 */
	return apply_filters( 'the_title', $post_title, $post_id );
}
```

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

- 0.71 — Introduced.

## Связанные

Использует: [`__`](https://chugunov.pro/api-wordpress/functions/__/), [`is_admin`](https://chugunov.pro/api-wordpress/functions/is_admin/), [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/), [`get_post`](https://chugunov.pro/api-wordpress/functions/get_post/).
Используется в: `WP_REST_Global_Styles_Controller::prepare_item_for_response`, [`get_adjacent_image_link`](https://chugunov.pro/api-wordpress/functions/get_adjacent_image_link/), `WP_REST_Post_Search_Handler::prepare_item`, [`get_the_privacy_policy_link`](https://chugunov.pro/api-wordpress/functions/get_the_privacy_policy_link/), `WP_REST_Revisions_Controller::prepare_item_for_response`, `WP_REST_Posts_Controller::prepare_item_for_response`, [`wp_embed_excerpt_more`](https://chugunov.pro/api-wordpress/functions/wp_embed_excerpt_more/), [`get_post_embed_html`](https://chugunov.pro/api-wordpress/functions/get_post_embed_html/), [`get_oembed_response_data`](https://chugunov.pro/api-wordpress/functions/get_oembed_response_data/), [`_draft_or_post_title`](https://chugunov.pro/api-wordpress/functions/_draft_or_post_title/), [`wp_prepare_revisions_for_js`](https://chugunov.pro/api-wordpress/functions/wp_prepare_revisions_for_js/), `WP_Comments_List_Table::column_response`, `Walker_Nav_Menu_Edit::start_el`, [`_wp_ajax_menu_quick_search`](https://chugunov.pro/api-wordpress/functions/_wp_ajax_menu_quick_search/), `WP_Widget_Recent_Comments::widget`, `WP_Widget_Recent_Posts::widget`, [`get_the_title_rss`](https://chugunov.pro/api-wordpress/functions/get_the_title_rss/), [`the_title`](https://chugunov.pro/api-wordpress/functions/the_title/), [`the_title_attribute`](https://chugunov.pro/api-wordpress/functions/the_title_attribute/), `wp_xmlrpc_server::_prepare_comment`, [`trackback_rdf`](https://chugunov.pro/api-wordpress/functions/trackback_rdf/), [`comments_popup_link`](https://chugunov.pro/api-wordpress/functions/comments_popup_link/), `_WP_Editors::wp_link_query`.

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