apply_filters( ‘pre_get_document_title’, string $title )

Filters the document title before it is generated.

Description

Passing a non-empty value will short-circuit wp_get_document_title() , returning that value instead.

Parameters

$titlestring
The document title. Default empty string.

Source

$title = apply_filters( 'pre_get_document_title', '' );

Changelog

VersionDescription
4.4.0Introduced.

User Contributed Notes

  1. Skip to note 4 content

    If you want to change the archive page title of your custom post type then use this code:

    function change_custom_post_type_archive_title( $title ) {
        if ( is_post_type_archive( 'your-custom-post-type' ) ){
            $title = 'My Custom post type archive - ' . get_bloginfo('name');
            return $title;
        }
        return $title;
    }
    
    add_filter( 'pre_get_document_title', 'change_custom_post_type_archive_title', 9999 );

You must log in before being able to contribute a note or feedback.