How can i remove JUST the title tag from wp_head() function?

i'm using wordpress 4.6 i'd like to remove just the title tag automatically outputted by wordpress because need to hardcode the html title tag in the template.

i guess is something like this:

add_action('wp_head', '//remove title tag command');

but i didn't find any valid solution so far.

Topic wp-title title wp-head Wordpress

Category Web


add_filter( 'pre_get_document_title' , 'render_title' );
function render_title($title){
    return 'New title ';
}
add_filter(  'document_title_parts' , 'render_title' );
function render_title($parts){
    $parts["title"] = "My Prefix ". $parts["title"];
    return $parts;
}

if ( is_page('138') )
{
      add_filter( 'the_title', '__return_false' );
}

add_filter('wp_head', function () {
    if (!current_theme_supports('title-tag')) {
        return;
    }

    if (did_action('wp_head') || doing_action('wp_head') && is_single()) {
        $categories = get_the_category();
        // Assuming the post has many categories will take the first
        $category = reset($categories);

        if ($category) {
            echo '<title>' . $category->name . ' - ' . get_the_title() . '</title>' . "\n";
        }
    }
    echo '<title>' . wp_get_document_title() . '</title>' . "\n";
});

Wordpress 5.7.1 with Yoast SEO installed Working code is:

add_filter('document_title_parts', '__return_empty_array', 10);

You can see everything added to wp_head in the file /wp-includes/default-filters.php.

If your theme supports the title tag, you can remove it entirely with remove_action:

remove_action( 'wp_head', '_wp_render_title_tag', 1 );

Though it may be simpler/better to use remove_theme_support( 'title-tag' ) in a child theme, which is what _wp_render_title_tag checks before outputting the title tag.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.