m (→Resources) |
m (→Related: added link to filter for title text) |
||
| (3 intermediate revisions by 2 users not shown) | |||
| Line 32: | Line 32: | ||
* [http://generatewp.com/theme-support/ WordPress Theme Support Generator] | * [http://generatewp.com/theme-support/ WordPress Theme Support Generator] | ||
* [https://make.wordpress.org/core/2014/10/29/title-tags-in-4-1/ Make.WordPress.org announcement of title-tag] | * [https://make.wordpress.org/core/2014/10/29/title-tags-in-4-1/ Make.WordPress.org announcement of title-tag] | ||
| − | * [ | + | * [https://make.wordpress.org/themes/2015/08/25/title-tag-support-now-required/ Theme Review Team: Title tag support now required] |
| + | * [https://bravokeyl.com/exploring-title-tag-theme-feature/ Exploring title_tag theme feature] | ||
== Related == | == Related == | ||
{{Theme Support}} | {{Theme Support}} | ||
| + | |||
| + | Filter the title tag text with wp_title: https://developer.wordpress.org/reference/hooks/wp_title/ | ||
[[Category:Advanced Topics]] | [[Category:Advanced Topics]] | ||
Languages: English • Tag 日本語 (Add your language)
Title Tag is a theme feature, first introduced in Version 4.1. This feature allows themes to add document title tag to HTML <head>.
Since Version 4.1, themes should use add_theme_support() in the functions.php file in order to support title tag, like so:
add_theme_support( 'title-tag' );
To add backwards compatibility for older versions, use the following code:
<?php
if ( ! function_exists( '_wp_render_title_tag' ) ) {
function theme_slug_render_title() {
?>
<title><?php wp_title( '|', true, 'right' ); ?></title>
<?php
}
add_action( 'wp_head', 'theme_slug_render_title' );
}
?>
Theme Support:
add_theme_support(),
remove_theme_support(),
current_theme_supports()
Theme Features:
sidebar,
menus,
post-formats,
title-tag,
custom-background,
custom-header,
custom-logo,
post-thumbnails,
automatic-feed-links,
html5,
editor-style,
content_width
Filter the title tag text with wp_title: https://developer.wordpress.org/reference/hooks/wp_title/