Title Tags in WordPress 4.1

February 20, 2015

To make it easier for plugins and themes to manage the document title in WordPress, you should check out the following solution committed by John Blackbourn @johnbillion. This is a good way to make document titles fully customisable and it is forward compatible.

Begin by adding this to your theme functions file (functions.php):

function theme_slug_setup() {
add_theme_support( 'title-tag' );
add_action( 'after_setup_theme', 'theme_slug_setup' );

In order to enable support in existing themes without breaking backwards compatibility, theme authors can check if the callback function exists and add a shiv if it doesn’t. This should be included in your header:

if ( ! function_exists( '_wp_render_title_tag' ) ) :
function theme_slug_render_title() {

add_action( 'wp_head', 'theme_slug_render_title' );

Read more at https://make.wordpress.org/core/2014/10/29/title-tags-in-4-1/

Comments are Disabled

Our sites

Our work

“The work that Eleventh Edition have carried out has yielded great results so far and I would highly recommend them.”
The Argyll Hotel, Glasgow

View our work