时间:2014-01-26所属栏目: WordPress教程 来源: 热度:
wordpress小器材里默认的“近期评述”里,只表现评述者和评述文章页,并没有表现评述者所评述的内容。若想让它将评述内容表现出来,除了安装WP-RecentComments插件外,修改wordpress自己的文件也可以到达:
找到wordpress安装目次下的wp-includes/default-widgets.php文件,以防万一先备份下这个文件,再打开找到如下代码:
if ( $comments ) {
// Prime cache for associated posts. (Prime post term cache if we need it for permalinks.)
$post_ids = array_unique( wp_list_pluck( $comments, 'comment_post_ID' ) );
_prime_post_caches( $post_ids, strpos( get_option( 'permalink_structure' ), '%category%' ), false );
foreach ( (array) $comments as $comment) {
$output .= '<li class="recentcomments">' . /* translators: comments widget: 1: comment author, 2: post link */ sprintf(_x('%1$s on %2$s', 'widgets'), get_comment_author_link(), '<a href="' . esc_url( get_comment_link($comment->comment_ID) ) . '">' . get_the_title($comment->comment_post_ID) . '</a>') . '</li>';
}
}
修改为:
if ( $comments ) {
foreach ( (array) $comments as $comment) {
$output .= '<li class="recentcomments">' . /* translators: comments widget:
1: comment author, 2: post link */ sprintf(_x('%1$s 说: %2$s', 'widgets'),
get_comment_author_link(), '<a href="' . esc_url( get_comment_link($comment->comment_ID) ) . '">' . strip_tags( $comment->comment_content) . '</a>') . '</li>';
}
}
生涯后革新页面就能看到评述者的评述内容了。