WordPress 4.1 to Introduce Theme Support for the Title Tag

title-tag

WordPress 4.1 will be adding several major improvements for theme developers. Joost de Valk opened a ticket three years ago, requesting a better option for controlling the output of title tags. He proposed a patch that would output the title tag during the run of wp_head, based on whether the current theme has added theme_support. This implementation is finally gaining traction, after a great deal of discussion among WordPress contributors.

This week John Blackbourn, the lead for WordPress 4.1, committed a forward-compatible way for allowing plugin and theme authors to better customize the output of document titles. The upcoming release will introduce theme support for the title tag.

[php light=”true”]add_theme_support( ‘title-tag’ );[/php]

“By declaring support like this, themes acknowledge that they are not defining titles on their own and WordPress can add it safely without duplication,” core contributor Konstantin Obenland explained when outlining title tag support in his most recent post to the make/core blog.

He elaborated further on the three year long effort, saying that it also served to correct an ancient practice of Kubrick, which appended the the blog name to wp_title():

[php light=”true”]<title><?php wp_title(‘&laquo;’, true, ‘right’); ?> <?php bloginfo(‘name’); ?></title>[/php]

That practice became fairly standard in WordPress themes. The new theme support for the title tag will make it easier for plugins and themes to manage the document title.

New Template Functions for Archive Title and Descriptions

WordPress 4.1 also introduces a couple of new template functions for archive titles and descriptions:

  • get_the_archive_title() and the_archive_title() for returning/displaying the title of the current term, date, post type, post format, or author archive.
  • get_the_archive_description() and the_archive_description() for returning/displaying the description associated with the current term archive.

Developers will have these new functions at their disposal, thanks to efforts from Konstantin Obenland and Drew Jaynes.

If you’re in the business building WordPress themes, you will want to take note of how to use the new title tag with backwards compatibility, as outlined by Obenland.

At this time, plugin developers are discouraged from building functionality around theme support for title tags. “The long term plan is to enable users to manage document titles from their admin, independent of which theme they’re using,” Obenland explained. Changes in WordPress 4.1 are the first step towards making title tags more plugin friendly.

10

10 responses to “WordPress 4.1 to Introduce Theme Support for the Title Tag”

  1. It’s sad that it took this long for the title tag to be looked at. I’ve never used any SEO plug-ins except for Add Meta Tags because on some of the high-traffic WordPress sites we have or manage, we use Attracta.. SEO or XML Sitemap plug-ins have never been in our tool box.

  2. Is this such a great improvement? I use WordPress SEO not only for the page title and in most of the times I have another version for my page title than for the document title (and often a shorter version for the breadcrumbs). Sure there are SEO options for several premium themes, but I would never use them! Leave the important functions like SEO to the specialist and not the designer :)

    I hope there are more and bigger improvements for the next version.

  3. I really seems more and more to me that Word Press is more, or only about building themes not websites or website support.
    I have a word press website built by PSI (Profit Sense Innovations) I paid thousands to build me the site and did not get anything like I wanted or needed. And am finding word press community is the un-friendliest and hardest to try and get any help or answers from. Have left questions / comments on discussions to multiple people asking for help or for where to get with my site with no reply of any kind. Maybe I’m just not a proper member of your community? Just a word press website owner. But really think I have the wrong kind of website source for my or any business?

    Hector Garcia
    Emotobuys.com

  4. I wanted to answer a few of the comments and explain this in a bit of detail. This ticket was quite a big deal back when it was originally opened and made a lot of sense. If it had went into core back then, it would’ve been great for plugins like WP SEO because it would’ve solved one huge problem, which is to get theme authors to properly use the wp_title() function. That’s the thing that goes between the title tags in the header. See, if themes don’t use that function properly, it breaks the output of plugins that alter the title.

    However, there was another way to get theme authors to properly use it: make it a guideline for the theme review team. And, that’s exactly what TRT did. Any theme going through the WordPress.org system was forced to use the function correctly. We managed to fix this problem in the three years it took for this ticket to get pushed through.

    Now, what does this new thing do? Not much, actually. It certainly doesn’t fix the issue that was originally brought up. What it does do is mark a transition in which core WP has total control over the output of the title. It really is best that core WP is outputting the title in the head rather than the theme so that there’s no confusion if/when they do something like build a title tag editor into core (yuck).

    So, to sum up: this is basically a method to allow core to eventually do something that belongs in a plugin. It doesn’t fix any problems.

    @Olaf Lederer – No, this offers no current improvements. The new method is simply a different way to add the title tag to the header.

    @Marc Connor – It won’t change anything with plugins like Yoast’s in the least. Three years ago it would’ve been helpful.

Newsletter

Subscribe Via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.