# wp_get_document_title()

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

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

## Сигнатура

```php
wp_get_document_title(): string
```

## Описание

Возвращает заголовок документа для текущей страницы.

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

`string`

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

Файл: `wp-includes/general-template.php:1180`

```php
function wp_get_document_title() {

	/**
	 * Filters the document title before it is generated.
	 *
	 * Passing a non-empty value will short-circuit wp_get_document_title(),
	 * returning that value instead.
	 *
	 * @since 4.4.0
	 *
	 * @param string $title The document title. Default empty string.
	 */
	$title = apply_filters( 'pre_get_document_title', '' );
	if ( ! empty( $title ) ) {
		return $title;
	}

	global $page, $paged;

	$title = array(
		'title' => '',
	);

	// If it's a 404 page, use a "Page not found" title.
	if ( is_404() ) {
		$title['title'] = __( 'Page not found' );

		// If it's a search, use a dynamic search results title.
	} elseif ( is_search() ) {
		/* translators: %s: Search query. */
		$title['title'] = sprintf( __( 'Search Results for &#8220;%s&#8221;' ), get_search_query() );

		// If on the front page, use the site title.
	} elseif ( is_front_page() ) {
		$title['title'] = get_bloginfo( 'name', 'display' );

		// If on a post type archive, use the post type archive title.
	} elseif ( is_post_type_archive() ) {
		$title['title'] = post_type_archive_title( '', false );

		// If on a taxonomy archive, use the term title.
	} elseif ( is_tax() ) {
		$title['title'] = single_term_title( '', false );

		/*
		* If we're on the blog page that is not the homepage
		* or a single post of any post type, use the post title.
		*/
	} elseif ( is_home() || is_singular() ) {
		$title['title'] = single_post_title( '', false );

		// If on a category or tag archive, use the term title.
	} elseif ( is_category() || is_tag() ) {
		$title['title'] = single_term_title( '', false );

		// If on an author archive, use the author's display name.
	} elseif ( is_author() && get_queried_object() ) {
		$author         = get_queried_object();
		$title['title'] = $author->display_name;

		// If it's a date archive, use the date as the title.
	} elseif ( is_year() ) {
		$title['title'] = get_the_date( _x( 'Y', 'yearly archives date format' ) );

	} elseif ( is_month() ) {
		$title['title'] = get_the_date( _x( 'F Y', 'monthly archives date format' ) );

	} elseif ( is_day() ) {
		$title['title'] = get_the_date();
	}

	// Add a page number if necessary.
	if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) {
		/* translators: %s: Page number. */
		$title['page'] = sprintf( __( 'Page %s' ), max( $paged, $page ) );
	}

	// Append the description or site title to give context.
	if ( is_front_page() ) {
		$title['tagline'] = get_bloginfo( 'description', 'display' );
	} else {
		$title['site'] = get_bloginfo( 'name', 'display' );
	}

	/**
	 * Filters the separator for the document title.
	 *
	 * @since 4.4.0
	 *
	 * @param string $sep Document title separator. Default '-'.
	 */
	$sep = apply_filters( 'document_title_separator', '-' );

	/**
	 * Filters the parts of the document title.
	 *
	 * @since 4.4.0
	 *
	 * @param array $title {
	 *     The document title parts.
	 *
	 *     @type string $title   Title of the viewed page.
	 *     @type string $page    Optional. Page number if paginated.
	 *     @type string $tagline Optional. Site description when on home page.
	 *     @type string $site    Optional. Site title when not on home page.
	 * }
	 */
	$title = apply_filters( 'document_title_parts', $title );

	$title = implode( " $sep ", array_filter( $title ) );

	/**
	 * Filters the document title.
	 *
	 * @since 5.8.0
	 *
	 * @param string $title Document title.
	 */
	$title = apply_filters( 'document_title', $title );

	return $title;
}
```

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

- 4.4.0 — Introduced.

## Связанные

Использует: [`get_search_query`](https://chugunov.pro/api-wordpress/functions/get_search_query/), [`get_the_date`](https://chugunov.pro/api-wordpress/functions/get_the_date/), [`post_type_archive_title`](https://chugunov.pro/api-wordpress/functions/post_type_archive_title/), [`single_term_title`](https://chugunov.pro/api-wordpress/functions/single_term_title/), [`single_post_title`](https://chugunov.pro/api-wordpress/functions/single_post_title/), [`is_404`](https://chugunov.pro/api-wordpress/functions/is_404/), [`is_search`](https://chugunov.pro/api-wordpress/functions/is_search/), [`is_singular`](https://chugunov.pro/api-wordpress/functions/is_singular/), [`is_year`](https://chugunov.pro/api-wordpress/functions/is_year/), [`is_front_page`](https://chugunov.pro/api-wordpress/functions/is_front_page/), [`is_tax`](https://chugunov.pro/api-wordpress/functions/is_tax/), [`is_home`](https://chugunov.pro/api-wordpress/functions/is_home/), [`is_category`](https://chugunov.pro/api-wordpress/functions/is_category/), [`is_tag`](https://chugunov.pro/api-wordpress/functions/is_tag/), [`is_author`](https://chugunov.pro/api-wordpress/functions/is_author/), [`is_month`](https://chugunov.pro/api-wordpress/functions/is_month/), [`is_day`](https://chugunov.pro/api-wordpress/functions/is_day/), [`is_post_type_archive`](https://chugunov.pro/api-wordpress/functions/is_post_type_archive/), [`get_queried_object`](https://chugunov.pro/api-wordpress/functions/get_queried_object/), [`__`](https://chugunov.pro/api-wordpress/functions/__/), [`_x`](https://chugunov.pro/api-wordpress/functions/_x/), [`get_bloginfo`](https://chugunov.pro/api-wordpress/functions/get_bloginfo/), [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/).
Используется в: [`_wp_render_title_tag`](https://chugunov.pro/api-wordpress/functions/_wp_render_title_tag/), [`_block_template_render_title_tag`](https://chugunov.pro/api-wordpress/functions/_block_template_render_title_tag/), [`get_wp_title_rss`](https://chugunov.pro/api-wordpress/functions/get_wp_title_rss/).

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