I have addded a custom title tag for a custom post type in header.php like follows

if(is_singular( 'news' )){
global $wp_query;
$postid = $wp_query->post->ID;
echo '<title>'. get_the_title() .' of '. strip_tags(get_the_term_list( get_the_ID(), 'genre', '', ' ', '' )) .' read online</title>';

This code works fine but I just do not know how to remove default the WordPress title tag. So now all my single news post have 2 title tags. One is above the source code and one is WordPress's default title tag. How can I disable WP title tag for single news? The one that comes with wp_head() ?

  • 1
    You have a typo in the echo, </title instead of </title> – marcovega Jul 6 '15 at 21:49

The default <title> can be handled by a template as a direct input in header.php or by the theme setup or options screen in backend.

If your theme won't show up <title> tag in the header.php, then it's pretty likely than the functions.php file has something like this:

add_theme_support( 'title-tag' );

You can remove that line and it won't print the title tag in head, so you can do it manually.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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