惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Help Net Security
大猫的无限游戏
大猫的无限游戏
雷峰网
雷峰网
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 聂微东
V
Visual Studio Blog
爱范儿
爱范儿
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
美团技术团队
有赞技术团队
有赞技术团队
云风的 BLOG
云风的 BLOG
Google DeepMind News
Google DeepMind News
Blog — PlanetScale
Blog — PlanetScale
The Cloudflare Blog
Engineering at Meta
Engineering at Meta
博客园 - 三生石上(FineUI控件)
WordPress大学
WordPress大学
Vercel News
Vercel News
F
Fortinet All Blogs
Last Week in AI
Last Week in AI
M
MIT News - Artificial intelligence
小众软件
小众软件
月光博客
月光博客
A
About on SuperTechFans

老蒋部落

盘点edgeNAT优惠活动及各机房测试IP 包括韩国CN2云服务器和独立服务器 666Clouds小众家庭网络ISP VPS方案整理 - 原生IP家宅宽带且有CN2线路可选 WordPress批量替换文字和链接工具 - WPReplace插件使用教程 LisaHost丽萨主机VPS方案整理 - 家庭网络VPS优惠套餐、机房线路和选择建议 盘点NameCheap域名优惠码和最新活动及新客域名注册、转入和管理指导 Vultr VPS怎么样?盘点 Vultr 新人免费赠送余额福利及各机房分布选择和购买指南 最新CloudCone优惠年付便宜VPS整理 - 3个美国机房可小时计费及新用户购买指南 定期更新HostDare优惠码及便宜CN2 GIA 优化线路VPS方案 汇总整理 RackNerd 年付便宜VPS方案 低至$10.18 适合入门建站测试节点 UCloud 香港轻量云服务器怎么样?回内地专区配置、线路及适用场景分析 实测体验衡天云年付175元美国VPS网络线路和速度体验测试 5M 电信CN2优化 WordPress 综合搜索引擎主动提交插件 LeSEP - 支持 Google、Bing、百度、Yandex 和 IndexNow 飞牛 NAS 文件加密教程:飞牛同步 + Cryptomator 实现多端访问 HHOST日本VPS怎么样?亲测开通这台高配日本VPS速度和线路体验 近期WordPress升级版本有些勤快 不要懒惰要及时升级 HHOST 新增日本VPS机房 4G内存起步配置 接入SoftBank和IIJ BGP LeMTR 实现中国三网(电信 / 联通 / 移动)回程路由一键测试脚本 衡天云年付163元日本云服务器网络线路速度实测体验 - 2M电信CN2线路 LeLocalSpeedTest - 一键部署可视化浏览器端SpeedTest上传下载测试脚本 LeOneClickWP - 一键云服务器部署WordPress站点 便于WebPageTest测速 LOCVPS云服务器VPS活动套餐整理 - 香港美国日本韩国等多机房CN2原生IP 衡天云入门型年付146元香港云服务器怎么样?搞一台测试稳定性和线路速度体验 HawkHost vs Bluehost:这2个海外虚拟主机哪个更值得选择? 景安网络域名解锁获取转移码转出服务商攻略 CstoneCloud七夕全场限时六折活动 - 低至24元可选英国/美国住宅9929优化双ISP VPS HawkHost vs SiteGround vs Hostinger:出海独立站虚拟主机深度对比与选择指南 国内外闲置域名交易平台整理:域名出售、买卖与抢注平台推荐 Lightlayer 多款特惠云服务器年付24美元 包括台湾 美国 菲律宾机房 对比WPWaterMark和LeWaterMaker两个WordPress水印插件区别和选择 WordPress 多语言翻译插件选择 TranslatePress 还是 Polylang Pro 对比
3个实用的WordPress禁用评论方法(无需插件)
老蒋 · 2026-07-22 · via 老蒋部落

对于国内的网站,我们无法控制网友评论的规范,所以一般我们的做法就是禁止评论。在对于WordPress程序中,如何实现禁止评论呢?我们可能看到有一些插件可以禁止,或者有主题自带禁止的。在这里,我们整理几个可以自定义设置禁止WordPress评论的方法。

1、系统设置

3个实用的WordPress禁用评论方法(无需插件)

在设置-讨论选项中,禁止对于新帖子的评论。当然我们也可以禁止注册。

2、用代码全站禁止

在LESEO插件中,老蒋也有设置支持一键禁止评论,这里如果我们不用这些插件,可以用到代码替换。

/**
 * Disable WordPress comments completely.
 * Add to your child theme's functions.php or a custom snippet.
 */

// Close comments and pingbacks on the front end for all post types.
function wpc_disable_comments_status() {
	return false;
}
add_filter( 'comments_open', 'wpc_disable_comments_status', 20, 2 );
add_filter( 'pings_open', 'wpc_disable_comments_status', 20, 2 );

// Hide existing comments so none display publicly.
function wpc_hide_existing_comments( $comments ) {
	return array();
}
add_filter( 'comments_array', 'wpc_hide_existing_comments', 10, 2 );

// Remove comment support from every post type in the admin.
function wpc_disable_comments_post_types_support() {
	$post_types = get_post_types();
	foreach ( $post_types as $post_type ) {
		if ( post_type_supports( $post_type, 'comments' ) ) {
			remove_post_type_support( $post_type, 'comments' );
			remove_post_type_support( $post_type, 'trackbacks' );
		}
	}
}
add_action( 'admin_init', 'wpc_disable_comments_post_types_support' );

// Remove the Comments item from the admin menu.
function wpc_remove_comments_admin_menu() {
	remove_menu_page( 'edit-comments.php' );
}
add_action( 'admin_menu', 'wpc_remove_comments_admin_menu' );

// Remove Comments from the admin bar at the top of the screen.
function wpc_remove_comments_admin_bar( $wp_admin_bar ) {
	$wp_admin_bar->remove_node( 'comments' );
}
add_action( 'admin_bar_menu', 'wpc_remove_comments_admin_bar', 999 );

// Redirect anyone who tries to reach the comments admin page.
function wpc_redirect_comments_admin_page() {
	global $pagenow;
	if ( 'edit-comments.php' === $pagenow ) {
		wp_safe_redirect( admin_url() );
		exit;
	}
}
add_action( 'admin_init', 'wpc_redirect_comments_admin_page' );

// Remove the Comments widget from the dashboard.
function wpc_remove_comments_dashboard_widget() {
	remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal' );
}
add_action( 'admin_init', 'wpc_remove_comments_dashboard_widget' );

添加到对应主题下面的 Functions.php 中实现禁止评论。

3、删除评论栏目

这里我们可以设置移除评论表单。

/**
 * Remove the comments column from post and page list tables.
 */
function wpc_remove_comments_column( $columns ) {
	unset( $columns['comments'] );
	return $columns;
}
add_filter( 'manage_posts_columns', 'wpc_remove_comments_column' );
add_filter( 'manage_pages_columns', 'wpc_remove_comments_column' );

这样,我们就可以通过这3个方式禁止评论。

原创文章,转载请注明出处:https://www.itbulu.com/disable-wpcomment.html