WordPress now has a hook for the automatic creation of document title tags, which is called in the wp_head action. Before this option, most themes were using the wp_title PHP tag to display the title for the current page.

After this hook is added, the wp_title section is no longer necessary and it can be removed from code if you are seeing a duplicate title issue.

The automatic creation of title tags is very useful for SEO practices. Because the WordPress title tag structure can change depending on the context of the page. This new hook removes all borders around the old fixed prefix-suffix structure and helps SEO plugins to configure the best SEO title structure automatically. Most of the time, the title structure is pre-configured on your WordPress SEO plugin, so you do not have to worry about anything.

In this post, we are describing the steps required to add theme support for title tags in WordPress.


1. Add Theme Support for Automatic Title Tags

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

2. Remove <title> Tags From Header Template

After you add theme support, you have to remove the <title> tag from your header.php file. If you do not remove this extra title tag in the theme file, you will start getting duplicate title tag errors. Removing this tag will fix this duplicate title tags error on your WordPress blog.


That’s it. After you complete those steps, your title tag is now automatically generated by WordPress.

Read More: Best Page Title Separator for SEO

 

How to Fix Duplicate Title Tags in WordPress

If you are getting duplicate title tags error on your SEO audit, this means your page titles are automatically generated by WordPress or an SEO plugin. Then you don’t need to have the wp_title function call in your theme header file (generally header.php).

This issue can be solved quickly by disabling the automatic generation of titles from SEO plugin settings. However, that is not a recommended fix. The best way to solve the “duplicate title tags” error is to remove <title><?php wp_title ... ?></title> code from your theme header file. This way you will only have title tags generated automatically by WordPress or your SEO plugin and duplication will be resolved.

 

How to Add Title Tags in WordPress

Because of this new feature, most WordPress themes removed <title> tags from the header.php template. However, title tags should be automatically added using the wp_head action hook. If you are not seeing title tags on your page, there may be a filter preventing this hook run on the page. If wp_head function call doesn’t exist on your header.php file, you may need to re-add it manually.

Generally, SEO plugins are able to check header output to prevent duplicate title tags on your site’s front end. If you are not already using one, we recommend you install a good SEO plugin for WordPress to prevent any SEO issues before they reflect on your search engine listings.

Read More: Change WordPress Default Title Separator