一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

WordPress文章显示评论内容而不是标题

时间:2013-09-07 编辑:简简单单 来源:一聚教程网

 

首先找到根目录下的 wp_includes/default-widgets.php,在functionwidget`(第625行左右)里面找

到以下代码(第655行左右):

 代码如下 复制代码

if ( $comments ) {
     foreach ( (array) $comments as $comment) {
     $output .= '

  • ' . /* translators: comments widget: 1: comment

    author, 2: post link */ sprintf(_x('%1$s on %2$s', 'widgets'), get_comment_author_link(),

    '' . get_the_title

    ($comment->comment_post_ID) . '') . '

  • ';
         }
    }

    将第三行中的

     代码如下 复制代码

    get_the_title($comment->comment_post_ID) 改成 strip_tags( $comment-

    >comment_content),

    同时将sprintf里的on改成你想要显示的文字,如『说』,这样样式就变成

    『评论者』说『评论内容』 以下是修改后的代码(注意:修改代码前请先备份)

     代码如下 复制代码

    if ( $comments ) {
         foreach ( (array) $comments as $comment) {
         $output .= '

  • ' . /* translators: comments widget: 1: comment

    author, 2: post link */ sprintf(_x('%1$s said: %2$s', 'widgets'), get_comment_author_link

    (), '' . strip_tags

    (($comment->comment_content) . '') . '

  • ';
         }
    }

    其实这个$output就是输出html代码,所以可以在此根据自己的需要作出修改。

    热门栏目