有几种方法可以实现这一点。我不建议删除编辑评论。php,因为这正在更改核心文件,当您更新WordPress时,您所做的更改将丢失。
htaccess
301 Redirect /wp-admin/edit-comments.php http://www.example.com/wp-admin/
或函数。php第1部分
// Redirect any user trying to access comments page
function custom_disable_comments_admin_menu_redirect() {
global $pagenow;
if ($pagenow === \'edit-comments.php\') {
wp_redirect(admin_url()); exit;
}
}
add_action(\'admin_init\', \'custom_disable_comments_admin_menu_redirect\');
第2部分
// Remove the menu item for comments from the side
function custom_disable_comments_admin_menu() {
remove_menu_page(\'edit-comments.php\');
}
add_action(\'admin_menu\', \'custom_disable_comments_admin_menu\');
第3部分
// Remove comments links from admin bar
function custom_disable_comments_admin_bar() {
if (is_admin_bar_showing()) {
remove_action(\'admin_bar_menu\', \'wp_admin_bar_comments_menu\', 60);
}
}
add_action(\'init\', \'custom_disable_comments_admin_bar\');