删除后台标题中的WordPress后缀

quality,Q 70

1638632976 20211204154936 61ab8e1079914

1638632976 20211204154936 61ab8e10822dc

WordPress后台标题(title)默认后缀显示-WordPress,如果想隐藏这个后缀,可以将下面代码添加到当前主题functions.php中,即可删除这个后缀:

去除后台标题中的“- WordPress”

  1. // 去除后台标题中的“—— WordPress”
  2. add_filter(‘admin_title’, ‘zm_custom_admin_title’, 10, 2);
  3. function zm_custom_admin_title($admin_title$title){
  4.     return $title.’ ‹ ‘.get_bloginfo(‘name’);
  5. }

去除登录标题中的“- WordPress”

  1. // 隐藏后台标题中的“WordPress”
  2. add_filter(‘login_title’, ‘zm_custom_login_title’, 10, 2);
  3.     function zm_custom_login_title($login_title$title){
  4.         return $title.’ ‹ ‘.get_bloginfo(‘name’);
  5. }

附:隐藏后台其它明显与WordPress相关的字样和图标

隐藏后台左上角WordPress标志

  1. // 隐藏左上角WordPress标志
  2. function hidden_admin_bar_remove() {
  3.     global $wp_admin_bar;
  4.         $wp_admin_bar->remove_menu(‘wp-logo’);
  5. }
  6. add_action(‘wp_before_admin_bar_render’, ‘hidden_admin_bar_remove’, 0);

屏蔽后台页脚WordPress版本信息

  1. // 屏蔽后台页脚WordPress版本信息
  2. function change_footer_admin () {return ;}
  3. add_filter(‘admin_footer_text’, ‘change_footer_admin’, 9999);
  4. function change_footer_version() {return ;}
  5. add_filter( ‘update_footer’, ‘change_footer_version’, 9999);

移除WordPress仪表盘中的项目

  1. function remove_dashboard_meta() {
  2.     remove_meta_box( ‘dashboard_incoming_links’, ‘dashboard’, ‘normal’ );
  3.     remove_meta_box( ‘dashboard_plugins’, ‘dashboard’, ‘normal’ );
  4.     remove_meta_box( ‘dashboard_primary’, ‘dashboard’, ‘side’ );
  5.     remove_meta_box( ‘dashboard_secondary’, ‘dashboard’, ‘normal’ );
  6.     remove_meta_box( ‘dashboard_quick_press’, ‘dashboard’, ‘side’ );
  7.     remove_meta_box( ‘dashboard_recent_drafts’, ‘dashboard’, ‘side’ );
  8.     remove_meta_box( ‘dashboard_recent_comments’, ‘dashboard’, ‘normal’ );
  9.     remove_meta_box( ‘dashboard_right_now’, ‘dashboard’, ‘normal’ );
  10.     remove_meta_box( ‘dashboard_activity’, ‘dashboard’, ‘normal’);//since 3.8
  11. }
  12. add_action( ‘admin_init’, ‘remove_dashboard_meta’ );

参考:https://codex.wordpress.org/Dashboard_Widgets_API

更多相关代码请阅读

 屏蔽WordPress后台无用项

类似文章