今天,老蒋正常打开网站后台的时候发现一个怪事,WordPress后台评论内容都不显示,包括之前评论的内容也看不到,只可以看到评论者的用户名等信息。记得这个问题在之前有一次也遇到,后来我也忘记是如何处理的。于是我正常刷新缓存、更新最新版本WordPress也无济于事。

我们看到的是这样子的。如果去编辑评论是可以看到有内容的,就是不显示出来。于是寻找解决方法。
第一、解决方法
1、寻找替换文件


wp-includes/comment-template.php

2、替换脚本
将:

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

替换成:

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


第二、检查是否解决
然后再刷新缓存,看看评论处的内容是不是解决。当然,问题是可以解决的。
目前,老蒋没有找到更好的解决方法,有网友说换主题可以解决,但这个动作有点大。因为之前是好的,为什么突然这样?是新版本WP的主题兼容问题还是什么。因为上面的解决方法是动了核心程序,下次如果升级WP的时候还会还原。所以我们下次更新版本后如果还这样就要继续修改。


扫描二维码,在手机上阅读!