REQUIRED: The <title> tags can...


#1

Has anyone managed to get rid of this message in theme check?

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

No matter what I do, it won’t go away.

This is what I have in my header

<?php wp_title(); ?>

#2

I have used it with the filter as the example in this page: http://codex.wordpress.org/Function_Reference/wp_title .

No problem with the Theme Check plugin. :wink:


#3

I have mine like this:

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

With no issues, maybe you’ve got some hidden characters in your title tags there?


#4

I also had this issue in my latest theme, published with it, didn’t get rejected. I have the exact same code as you Thommus, with some filters applied.


#5
tommusrhodus said

I have mine like this:

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

With no issues, maybe you’ve got some hidden characters in your title tags there?

Also using this with filter:

function oi_wp_title( $title, $sep ) {
	global $paged, $page;

	if ( is_feed() )
		return $title;

	$title .= get_bloginfo( 'name' );

	$site_description = get_bloginfo( 'description', 'display' );
	if ( $site_description && ( is_home() || is_front_page() ) )
		$title = "$title $sep $site_description";

	if ( $paged >= 2 || $page >= 2 )
		$title = "$title $sep " . sprintf( __( 'Page %s', 'orangeidea' ), max( $paged, $page ) );

	return $title;
}
add_filter( 'wp_title', 'oi_wp_title', 10, 2 );


#6
OrangeIdea said

Also using this with filter:

Yep :slight_smile:


#7

How about with the new 4.1 update, how can fix this issue in theme checker?

WordPress 4.1 uses

add_theme_support( ‘title-tag’ );


#8

I add the add_theme_support( ‘title-tag’ ) and I have the same error


#9

This error mean; there is an another </ title> tag found in your theme (not into the header.php). Check your files and remove it.


#10
Webbu said

This error mean; there is an another </ title> tag found in your theme (not into the header.php). Check your files and remove it.

+1


#11

add_theme_support( ‘title-tag’ );

This means that the title tag is added by the wp_head() and it is not required to be added as

<?php wp_title() ?>


#12
tommusrhodus said

I have mine like this:

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

With no issues, maybe you’ve got some hidden characters in your title tags there?

This was working like a treat for me before the update. Thanks for this btw.:slight_smile:

DJMiMi said

add_theme_support( ‘title-tag’ );

This means that the title tag is added by the wp_head() and it is not required to be added as

<?php wp_title() ?>

Yes I believe this is now a requirement for all themes. I think you get an error in theme check if you don’t use this…

Also I figured out what the problem to my issue was in case anyone is still having problems with getting this error to go away. I included ACF in my theme for the options panel and the plugin was using tags in the wrong places. So if the error won’t go away in Theme Check even though you are using the title tags correctly, check ACF.


#13

There is another title tag somewhere in your theme. Do a folder search with Sublime Text (or any other editor) for and remove all of those except for the one in your header.php


#14
DJMiMi said

add_theme_support( ‘title-tag’ );

This means that the title tag is added by the wp_head() and it is not required to be added as

<?php wp_title() ?>

+1 for
add_theme_support( 'title-tag' );

And you should wrap code in pre tag instead of code :slight_smile:


#15

I fix theme check RECOMMENDED: add_theme_support( ‘title-tag’ ); with this: http://www.binarymoon.co.uk/2014/11/wordpress-4-1-improvements-theme-developers/

Now I still have this two:

  1. RECOMMENDED: No reference to add_theme_support( “custom-header”, $args ) was found in the theme. It is recommended that the theme implement this functionality if using an image for the header.

  2. RECOMMENDED: Tags: is either empty or missing in style.css header.

All tags are in css header but something make confusion in theme check.


#16

Hi guys I have resolved for this issue following.

1: My Old Header.php file is like this.

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

And i have removed this code on header.php currenlty.

2: After WP 4.1 update Title is no longer supported and only adding functions.php file for following code.

add_theme_support( 'title-tag' );

I have tested it on my local and also with SEO by Yoast plugin everythings work fine currently.

Themeforest Reviewers also requiring this.
Any other Points?


#17

This is how we do it:

if ( ! function_exists( '_wp_render_title_tag' ) ) {

	add_action( 'wp_head', array( $this, 'pe_theme_render_title' ) );

}

public function pe_theme_render_title() {

	?>

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

	<?php

}

add_theme_support( 'title-tag' );

That way you support both newer and older versions of WordPress


#18
Medians_ said

I fix theme check RECOMMENDED: add_theme_support( ‘title-tag’ ); with this: http://www.binarymoon.co.uk/2014/11/wordpress-4-1-improvements-theme-developers/

Now I still have this two:

  1. RECOMMENDED: No reference to add_theme_support( “custom-header”, $args ) was found in the theme. It is recommended that the theme implement this functionality if using an image for the header.

  2. RECOMMENDED: Tags: is either empty or missing in style.css header.

All tags are in css header but something make confusion in theme check.

1.) Not important, but if you really want it gone, just add this to your theme:

// add_theme_support( 'custom-header' );

2.) Make sure you add tags to any file that is named style.css, not just the main one in the root folder of your theme.