Title tag support now required

As of today’s team meeting, title-tag support is now required for all themes. We keep a back-compatibility policy of two versions, and the title tag feature was added in WordPress 4.1. So, we’re at that point.

The team has put up a ticket to get this added to the Theme Check pluginPlugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party, so it should be an automatic check with no need for manual checking from reviewers once it gets rolled in.

This post is primarily a heads up for theme authors.

Do I have to change my code?

It depends. I think most new themes are already adding support. If not, you simply need to add a single line within your theme setup function, which would look something like the following.

add_action( 'after_setup_theme', 'theme_slug_setup' );

function theme_slug_setup() {

	add_theme_support( 'title-tag' );
}

Removing back-compat code

If you previously had code to handle pre-4.1 installs, you can simply remove it. That code would look something like this:

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' );
}

Also, make sure the following is not in your header.php template:

<title><?php wp_title( '|', true, 'right' ); ?></title>