Snippets › Modify WordPress v4.4 + header title

As we all know wp_title() is being deprecated as of WordPress 4.4. it is recommended that you instead use its replacement: the title-tag theme feature. Here's the WordPress filter to modify the header initiated by wp_get_document_title.

Replace whole title tag with pre_get_document_title filter:

add_filter( 'pre_get_document_title' , 'render_title' );
function render_title($title){
    return 'New title ';
}

Or with document_title_parts get more creative.

add_filter(  'document_title_parts' , 'render_title' );
function render_title($parts){
    $parts["title"] = "My Prefix ". $parts["title"];
    return $parts;
}

I would love to hear other improved ways to do this, hope it helps!