Filter hook 'pre_get_document_title'

in WP Core File wp-includes/general-template.php at line 1188

View Source

pre_get_document_title

Filter Hook
Description
Filters the document title before it is generated. Passing a non-empty value will short-circuit wp_get_document_title(), returning that value instead.

Hook Information

File Location wp-includes/general-template.php View on GitHub
Hook Type Filter
Line Number 1188

Hook Parameters

Type Name Description
string $title The document title. Default empty string.

Usage Examples

Basic Usage
<?php
// Hook into pre_get_document_title
add_filter('pre_get_document_title', 'my_custom_filter', 10, 1);

function my_custom_filter($title) {
    // Your custom filtering logic here
    return $title;
}

Source Code Context

wp-includes/general-template.php:1188 - How this hook is used in WordPress core
<?php
1183  	 *
1184  	 * @since 4.4.0
1185  	 *
1186  	 * @param string $title The document title. Default empty string.
1187  	 */
1188  	$title = apply_filters( 'pre_get_document_title', '' );
1189  	if ( ! empty( $title ) ) {
1190  		return $title;
1191  	}
1192  
1193  	global $page, $paged;

PHP Documentation

<?php
/**
	 * 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.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 1
  • File: wp-includes/general-template.php
Related Hooks

Related hooks will be displayed here in future updates.