$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>The <title> tags can only contain a call to wp_title(). Use the wp_title filter to modify the output|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

The <title> tags can only contain a call to wp_title(). Use the wp_title filter to modify the output

matteradmin7PV0评论

I am submitting my theme to WordPress. To make it compatible with WordPress 4.1 and greater, I replaced wptitle() tag with add_theme_support( 'title-tag' ) but now the error has changed to following:

REQUIRED: The <title> tags can only contain a call to wp_title(). Use the wp_title filter to modify the output

Here is a snippet from my header code:

<head>
    <meta charset="<?php bloginfo( 'charset' ); ?>">
    <meta name="viewport" content="width=device-width">
    <title><?php add_theme_support( 'title-tag' ); ?></title>
    <link rel="profile" href="">
    <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
    <!--[if lt IE 9]>
    <script src="<?php echo get_template_directory_uri(); ?>/js/html5.js"></script>
    <![endif]-->
    <?php wp_head(); ?>
</head>

I have read this Github discussion and this StackOverflow question to solve my problem.

I am submitting my theme to WordPress. To make it compatible with WordPress 4.1 and greater, I replaced wptitle() tag with add_theme_support( 'title-tag' ) but now the error has changed to following:

REQUIRED: The <title> tags can only contain a call to wp_title(). Use the wp_title filter to modify the output

Here is a snippet from my header code:

<head>
    <meta charset="<?php bloginfo( 'charset' ); ?>">
    <meta name="viewport" content="width=device-width">
    <title><?php add_theme_support( 'title-tag' ); ?></title>
    <link rel="profile" href="http://gmpg/xfn/11">
    <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
    <!--[if lt IE 9]>
    <script src="<?php echo get_template_directory_uri(); ?>/js/html5.js"></script>
    <![endif]-->
    <?php wp_head(); ?>
</head>

I have read this Github discussion and this StackOverflow question to solve my problem.

Share Improve this question edited May 23, 2017 at 12:40 CommunityBot 1 asked Sep 20, 2015 at 11:26 user2238user2238
Add a comment  | 

2 Answers 2

Reset to default 2

add_theme_support( 'title-tag' ) doesn't belong in your header template. It belongs in your functions.php file. Usually, it's best to wrap it in it's own function and hook it to after_setup_theme in order to allow plugins and child themes to override it later if they need to. So...

function wpse_add_title_support() {
    add_theme_support( 'title-tag' );
}
add_action ( 'after_setup_theme', 'wpse_add_title_support' );

Once you have declared title support, you can remove the <title> tag from header.php altogether and WP will handle putting it in.

I solved this way:

<title><?php wp_title( '|', true, 'right' ); ?></title>

and write this into after_setup_theme function add_theme_support( 'title-tag' );

Post a comment

comment list (0)

  1. No comments so far