Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Title Tag

Title Tag is a theme feature, first introduced in Version 4.1. This feature allows themes to add document title tag to HTML <head>.

Adding Theme Support

Since Version 4.1, themes should use add_theme_support() in the functions.php file in order to support title tag, like so:

add_theme_support( 'title-tag' );

Backwards Compatibility

To add backwards compatibility for older versions, use the following code:

<?php
if ( ! function_exists( '_wp_render_title_tag' ) ) {
	function theme_slug_render_title() {
?>
<title><?php wp_title( '|', true, 'right' ); ?></title>
<?php
	}
	add_action( 'wp_head', 'theme_slug_render_title' );
}
?>

Resources

Related

Theme Support: add_theme_support(), remove_theme_support(), current_theme_supports()
Theme Features: sidebar, menus, post-formats, title-tag, custom-background, custom-header, custom-logo, post-thumbnails, automatic-feed-links, html5, editor-style, content_width

Filter the title tag text with wp_title: https://developer.wordpress.org/reference/hooks/wp_title/