默认情况下,在WordPress 后台页面的标题的尾部,都有 “​—— WordPress​”这一段,比如“仪表盘 < 控制台 —— WordPress”,有些朋友出于某些目的,需要去掉最后的 “—— WordPress”,其实方法比较简单,用到 admin_title 这个过滤挂钩。具体的代码如下:

/**
* WordPress 去除后台标题中的“—— WordPress”
* http://www.wpdaxue.com/remove-wordpress-from-admin-title.html
* 参考代码见 https://core.trac.wordpress.org/browser/tags/4.2.2/src/wp-admin/admin-header.php#L44
*/
add_filter('admin_title', 'wpdx_custom_admin_title', 10, 2);
function wpdx_custom_admin_title($admin_title, $title){
return $title.' &lsaquo; '.get_bloginfo('name');
}

当然你可以直接找到相关php文件,找到​wp-admin/admin-header.php

if ( $admin_title == $title )
$admin_title = sprintf( __( '%1$s &#8212; WordPress' ), $title );
else
$admin_title = sprintf( __( '%1$s &lsaquo; %2$s &#8212; WordPress' ), $title, $admin_title );

修改为

if ( $admin_title == $title )
$admin_title = sprintf( __( '%1$s' ), $title );
else
$admin_title = sprintf( __( '%1$s &lsaquo; %2$s' ), $title, $admin_title );

在主题中使用钩子的好处就是每次更新wordpress时候,不用每次都修改admin-header.php文件