通常情况下我们是不需要网站的评论功能的,所以希望从后台的左导航中删除“评论”使导航更加简洁。下面的方法仅仅是从导航项目中去掉“评论”,并不是在网站中完全禁用“评论”。

function d7856_remove_admin_menus(){
    remove_menu_page('edit-comments.php');
}
add_action('admin_menu', 'd7856_remove_admin_menus');

remove_menu_page函数

下面的代码可以删除左导航中的特定项目,可尝试。

/**
 * Removes some menus by page.
 */
function wpdocs_remove_menus(){
   
  remove_menu_page( 'index.php' );                  //Dashboard
  remove_menu_page( 'jetpack' );                    //Jetpack* 
  remove_menu_page( 'edit.php' );                   //Posts
  remove_menu_page( 'upload.php' );                 //Media
  remove_menu_page( 'edit.php?post_type=page' );    //Pages
  remove_menu_page( 'edit-comments.php' );          //Comments
  remove_menu_page( 'themes.php' );                 //Appearance
  remove_menu_page( 'plugins.php' );                //Plugins
  remove_menu_page( 'users.php' );                  //Users
  remove_menu_page( 'tools.php' );                  //Tools
  remove_menu_page( 'options-general.php' );        //Settings
   
}
add_action( 'admin_menu', 'wpdocs_remove_menus' );
?>
相关文章:
https://10.1pxeye.com/wordpress%e9%98%b2%e5%be%a1%e5%9e%83%e5%9c%be%e8%af%84%e8%ae%ba%e7%9a%84%e6%96%b9%e6%b3%95%e4%b8%80%e5%88%99/
https://10.1pxeye.com/wordpress%e4%bb%8e%e7%bc%96%e8%be%91%e5%99%a8%e9%a1%b5%e9%9d%a2%e4%b8%ad%e5%88%a0%e9%99%a4%e8%af%84%e8%ae%ba%e9%80%89%e9%a1%b9%e5%8d%a1%ef%bc%88%e8%af%84%e8%ae%ba%e7%9b%b8%e5%85%b3%e8%ae%be%e7%bd%ae/