admin管理员组

文章数量:1278986

When editing a lot of pages at once, it would be helpful to change the default "Edit page < sitename - Wordpress" to something more clear, like the page/post title.

I found a few code snippets, like the one below, that doesn't work, I just get an empty page title.

Using WordPress 5.8.2 and have the code infunctions.php.

add_filter('admin_title', 'better_admin_title', 10, 2);

function better_admin_title($admin_title, $title)
{
    global $post, $title, $action, $current_screen;
    if (is_admin() and $action == 'edit' and in_array($current_screen->id, ['post', 'page'])) {
        return $title . ' ‹ ' . $post->post_title . ' — ' . get_bloginfo('name');
    }

    return $admin_title;
}

本文标签: Change the default PostPage edit title in Admin