Since WordPress 4.1, WordPress allows automatic creation of document title tags. This is a very useful option for most SEO practices because the title tag structure can change depending on the context of page.
To enable automatic title tags, first, you need to add theme support in your theme setup function:
add_theme_support( 'title-tag' ); // Enable automatic title tags
After you add theme support, you have to remove
<title> tag from your
header.php file. Otherwise, you can get duplicate title tags, which is bad for page SEO.
That’s it. After you complete those steps, your title tag is now automatically generated by WordPress.
This function also enables SEO plugins to better manage your site’s SEO titles.