[wp-trac] [WordPress Trac] #52314: the HTML <title> tag for Edit Post should include the post's title
WordPress Trac
noreply at wordpress.org
Sat Jan 16 03:03:30 UTC 2021
#52314: the HTML <title> tag for Edit Post should include the post's title
-------------------------+------------------------------
Reporter: skierpage | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Editor | Version: 5.6
Severity: minor | Resolution:
Keywords: | Focuses: administration
-------------------------+------------------------------
Changes (by alexstine):
* type: defect (bug) => enhancement
Comment:
@skierpage Thanks for submitting a ticket.
I am not 100% for sure, but I'd say the reason why this isn't included in
core is because of the recommended length for the "title" tag. Please see
here.
https://www.w3.org/Provider/Style/TITLE.html
The title should ideally be less than 64 characters in length.
That being said, you are not out of options. There is a core filter called
"admin_title" and you can use it to adjust this for the post screen.
https://developer.wordpress.org/reference/hooks/admin_title/
Here's a small snippet that I wrote on my test site. Do not use this in
production until testing to make sure it works well for you. It will
generate a title that looks like this.
{{{
<title>Edit Post: Testing ‹ example.com — WordPress</title>
}}}
This should work well across pages and posts. I tested using Classic
Editor and Gutenberg.
{{{#!php
add_filter( 'admin_title', 'change_admin_title_posts_screen', 10, 2 );
function change_admin_title_posts_screen( $admin_title, $title ) {
global $post, $pagenow;
if ( isset( $pagenow ) && 'post.php' == $pagenow ) { // Make sure
we only change title on post.php
$new_title = sprintf( __( '%1$s: %2$s ‹ %3$s
— WordPress' ),
$title, // Edit Post
$post->post_title, // Post title
get_bloginfo( 'name' ) // Blog title
);
return $new_title; // Return new title
} else {
return $admin_title; // Sanity line to return default
title
}
}
}}}
That is using the custom filter, you can add that snippet in a custom mu-
plugin, plugin, or [https://developer.wordpress.org/themes/advanced-topics
/child-themes/ child theme] for testing.
I'd say if anything, this is likely an "Enhancement", not a "Bug." I could
not replicate any difference between Classic Editor and Gutenberg in 5.6.
Maybe others have an opinion on this?
Hope it helps. Thanks.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/52314#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list