WordPress设置文章草稿状态未发布也能评论

用过WordPress的人应该知道,WordPress文章在未发布时是不能评论的,但是作为一个勤奋的站长,我不需要这么玩意,因为我的文章大多是提前准备好的,为了提现出文章的活跃度,我需要提前在每一篇文章中添加评论。但是因为文章未发布时是不能评论的,所以我要取消这个限制。

解决方案

1、找到/wp-includes/comment.php文件

查找:if ( current_user_can( 'read_post', $comment_post_ID ) ) {

把下面这几行代码删掉

if ( current_user_can( 'read_post', $comment_post_ID ) ) {
			return new WP_Error( 'comment_on_draft', __( 'Sorry, comments are not allowed for this item.' ), 403 );
		} else {
			return new WP_Error( 'comment_on_draft' );
		}

OK,成功解决。

猜你喜欢

转载自blog.csdn.net/t1174148618/article/details/120199294