WordPress 4.4 and older themes – how to break backward compatibility

Since quite some time I was wondering why my blog suddenly does not display a title in the browser bar. Hmm, Of course I thought I broke something, but it turned out that this is a feature of a recent WordPress update. Mentioned in a blog entry on the development – or should I say, hidden there so that nobody knows about it – the changes stirred quite some reactions, not the least because a lot, if not all older themes, are suddenly broken. Congratulations WordPress developer to this great move.


So what has happened? Many themes use the wp_title function to ship out title tags. After a short period of deprecation WordPress developers instantiated the function, but in a way that it doesn’t work with older themes. Perfect.

To quote from the kind of annoucement:

This latest change makes the new API (almost) feature complete and theme authors are discouraged from using wp_title() in the future. If it was decided to add a UI to let users choose the make up of their document title, or another improvement to how title generation works, we now have a forward compatible way to handle these things.

To upgrade themes from using wp_title() to declaring theme support for core’s title-tag without breaking backwards compatibility with WordPress 4.0 and older, theme authors can check if the callback function exists and add a shiv in case it does not: …

Well, thanks for putting this well hidden in a development blog. Furthermore, one needs to read the following code quite carefully, otherwise one overlooks that it is necessary to delete the calls to wp_title.

Fortunately, on blog of the Theme Review Team the this post was found, which explains what has to be done:

  • add an action hook:
    add_action( 'after_setup_theme', 'theme_slug_setup' );
    function theme_slug_setup() { add_theme_support( 'title-tag' ); }
  • and above all, (quote) Also, make sure the following is not in your header.php template: <title><?php wp_title( '|', true, 'right' ); ?></title>

Indeed, that worked. Since I am already a child theme the changes were minimal, once one found them.

Coming from a TeX world, things like backward compatibility in other products always strike me as funny …

1 Response

  1. 2016/01/10

    […] WordPress 4.4 and older themes – how to break backward compatibility […]

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>