3

I am getting these three warnings while running the theme-check plugin.

REQUIRED: The theme must not used the <title> tags.

REQUIRED: The theme must not call to wp_title().

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

I am using this in my headers <title></title> tags.

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

Something has changed in WordPress or I am not following some concrete steps?

1 Answer 1

4

WordPress added support for the title-tag feature in version 4.1 and it's now a required feature for themes uploaded to the repo.

To implement this feature, make sure your theme does not have the title tag hard coded within header.php, e.g.:

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

Configure your theme with title-tag support like this:

add_action( 'after_setup_theme', 'wpse_theme_setup' );
function wpse_theme_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' );
}

To make changes to the title text, use the following filters (source):

4
  • Thank you so much, that is enlightening, but I could not understand this statement in its entirety → "To make changes to the title text, use the wp_title filter". Can you please elaborate?
    – WordCent
    Commented Apr 26, 2017 at 3:03
  • 1
    Happy to help! I've updated the answer with the updated list of filters used for modifying the title tag's output. Forget about the wp_title filter, that's the old school way. Commented Apr 26, 2017 at 3:12
  • I am also receiving this bug → REQUIRED: The <title> tags can only contain a call to wp_title(). Use the wp_title filter to modify the output; How to eliminate this bug?
    – WordCent
    Commented May 25, 2017 at 19:01
  • @TheWPNovice would you please edit your question and provide your your header.php template? Commented May 26, 2017 at 1:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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