如果您開發的主題,沒有出現標題,需要檢查一下當前主題是否包含:
add_theme_support( 'title-tag' );
如果主題中找不到,請在主題根目錄加入它,必須要在 after_setup_theme 這個 Hook 中,實際範例如下
if ( !function_exists( 'yourtheme_setup' ) ) {
function yourtheme_setup() {
/*
* Let WordPress manage the document title.
* By adding theme support, we declare that this theme does not use a
* hard-coded <title> tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
}
add_action( 'after_setup_theme', 'yourtheme_setup' );
}
https://wordpress.stackexchange.com/a/296877/116304
https://developer.wordpress.org/reference/functions/wp_title/