theme development - Is <title> tag default in WordPress?

admin2025-06-03  2

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()?

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()?

Share Improve this question edited Jan 31, 2019 at 9:04 Krzysiek Dróżdż 25.6k9 gold badges53 silver badges74 bronze badges asked Jan 31, 2019 at 8:51 Aftar FadilahAftar Fadilah 253 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 3

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' );
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748958817a315162.html

最新回复(0)