Make WordPress Core

Opened 5 months ago

Closed 3 months ago

Last modified 3 months ago

#61900 closed feature request (invalid)

Unable to remove hook to display title tag in block theme

Reported by: webbingstudio's profile webbingstudio Owned by:
Milestone: Priority: normal
Severity: normal Version: 6.6
Component: Themes Keywords:
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 (5)

#1 @sabernhardt
5 months ago

  • Component changed from General to Themes

#2 @poena
5 months 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

#3 @poena
3 months ago

  • Keywords close added

Hi @webbingstudio
Can I close this ticket? I believe this is resolved?

#4 @webbingstudio
3 months ago

  • Resolution set to invalid
  • Status changed from new to closed

Sorry for the late response...
It's resolved. I'll close the issue.
Thank you.

#5 @desrosj
3 months ago

  • Keywords needs-docs close removed
  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.