1

This may be a stupid questions but I have been building some themes. Some of them doesn't include the <title> in the head and some of the theme include it.

I belive some SEO plugin can add <meta> tag in the head but what about title?

So, is it because the SEO plugin or it is default by WordPress included in wp_head()?

2

Well, it's not a stupid question at all...

wp_title is a template tag and it was used for a long time (since 1.0.0) to put <title> tag in the header. This way plugins were able to modify the title with filters. In WP 4.4 it was about to be deprecated, but that idea was abandoned and you can still use that function.

On the other hand, you don't have to. Since WP 4.1 you can use title-tag theme feature instead.

So if your theme declares that it supports title-tag feature, then the title tag will be generated automatically and you don't have to put it manually in the header any more. And to declare that you're supporting such feature you need something like this in your code:

function theme_slug_setup() {
   add_theme_support( 'title-tag' );
}
add_action( 'after_setup_theme', 'theme_slug_setup' );
  • Thanks for making it clear. So the best practice would be inserting the title-tag support in my theme? – Aftar Fadilah Jan 31 at 9:19
  • 1
    Yes, that's the modern way – Krzysiek Dróżdż Jan 31 at 9:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.