fix: remove the block theme's title tag, not the classic one

The duplicate <title> survived the last release. Block themes swap
_wp_render_title_tag for _block_template_render_title_tag, so removing
the classic callback matched nothing and both titles kept rendering.

locate_block_template() registers the replacement during template_include,
after `wp` and template_redirect, so wp_head at priority 0 is the earliest
point where it can be removed before it runs.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
chrnxandClaude Opus 5 committed 2026-08-14 08:55:31 -05:00
1 parent f9191a18bc
commit e394b88ee6
23 files changed
+33 -25

No files matched your search

+11 -3
View File
@@ -98,11 +98,19 @@ function chrnx_has_seo_plugin(): bool {
/**
* Drop core's title tag when an SEO plugin prints its own.
*
* Both were rendering, so every page shipped two <title> elements.
* Both were rendering, so every page shipped two <title> elements. Block
* themes swap _wp_render_title_tag for the block-template renderer, so
* removing only the classic one silently did nothing here.
*
* locate_block_template() registers that renderer during template_include,
* after both `wp` and template_redirect, so wp_head is the first hook where
* it exists and can still be removed before it runs.
*/
function chrnx_remove_duplicate_title_tag() {
if ( chrnx_has_seo_plugin() ) {
remove_action( 'wp_head', '_wp_render_title_tag', 1 );
if ( ! chrnx_has_seo_plugin() ) {
return;
}
remove_action( 'wp_head', '_block_template_render_title_tag', 1 );
remove_action( 'wp_head', '_wp_render_title_tag', 1 );
}
add_action( 'wp_head', 'chrnx_remove_duplicate_title_tag', 0 );