WordPress评论内容不显示的解决方法

三好酋长昨天在处理评论时,发现无论是在WordPress后台还是前端文章页面,评论都只显示评论者,而不显示评论内容。在网上找到了如下解决方法,备忘一下:

编辑wp-includescomment-template.php。

function comment_text( $comment_ID = 0, $args = array() ) {
	$comment = get_comment( $comment_ID );

	$comment_text = get_comment_text( $comment, $args );
	/**
	 * Filters the text of a comment to be displayed.
	 *
	 * @since 1.2.0
	 *
	 * @see Walker_Comment::comment()
	 *
	 * @param string          $comment_text Text of the current comment.
	 * @param WP_Comment|null $comment      The comment object.
	 * @param array           $args         An array of arguments.
	 */
	echo apply_filters( 'comment_text', $comment_text, $comment, $args );
}

修改为:

function comment_text( $comment_ID = 0 ) {
 $comment = get_comment( $comment_ID );
 echo(get_comment_text( $comment_ID ));
}

如果你启用了缓存插件,那么可能需要删除缓存之后即可看到评论内容已经能够显示了。

You may also like...

1 Response

  1. shrimp说道:

    老兄,你的wordpress 版本是最新的吗? 还有PHP 的版本,我用php 7.1的版本 不显示评论了。。。

shrimp进行回复 取消回复

您的电子邮箱地址不会被公开。 必填项已用*标注