Make WordPress Core

Opened 7 weeks ago

Last modified 4 weeks ago

#61900 new feature request

Unable to remove hook to display title tag in block theme

Reported by: webbingstudio's profile webbingstudio Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 6.6
Component: Themes Keywords: needs-docs
Focuses: template Cc:

Description

As a simple SEO measure, there was a customization to remove the "_wp_render_title_tag" hook and then output an arbitrary title tag. There are also plugins that use this function.

Example: If you execute the following code, it is expected that the default title tag will no longer be output.

<?php
add_action( 'init', 'mytheme_render_title_tag', 1 );
function mytheme_render_title_tag() {
  remove_action( 'wp_head', '_wp_render_title_tag', 1 );
}

However, currently, the "_wp_render_title_tag" hook cannot be disabled in block themes. The default title tag remains output, and as a result, the title is displayed twice.

Is this expected behavior? If it is, could you please add an announcement that the hook can no longer be used and a document that describes how to deal with it in block themes?

*Of course, I understand that it is not desirable to directly interact with internal functions that start with an underscore.

Change History (2)

#1 @sabernhardt
6 weeks ago

  • Component changed from General to Themes

#2 @poena
4 weeks ago

Hi

Blocks themes use _block_template_render_title_tag to avoid having to declare theme support for the title.
It does the same thing as _wp_render_title_tag without the theme support condition, it echo's wp_get_document_title().

Plugin developers can use a filter for wp_get_document_title(), for example pre_get_document_title

Note: See TracTickets for help on using tickets.