wordpress小工具最新评论显示评论内容
Kdatacenter:$17.1/月/1G内存/100GB SSD空间/1TB流量/1Gbps端口/KVM/韩国SK/直连;原生IP
’ . /* translators: comments widget:
1: comment author, 2: post link */ sprintf(_x(‘%1$s : %2$s’, ‘widgets’),
get_comment_author_link(), ‘comment_ID) ) . ‘”>’ . mb_strimwidth(strip_tags($comment->comment_content),0,46,”,’utf-8′) . ‘’) . ‘ ’;
}
}
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 .= '' . /* translators: comments widget: 1: comment author, 2: post link */ sprintf(_x('%1$s on %2$s', 'widgets'), get_comment_author_link(), 'comment_ID) ) . '">' . get_the_title($comment->comment_post_ID) . '') . ' ';
}
}
改为:
(图片来源网络,侵删)
if ( $comments ) {
foreach ( (array) $comments as $comment) {
$output .= ‘
1: comment author, 2: post link */ sprintf(_x(‘%1$s : %2$s’, ‘widgets’),
get_comment_author_link(), ‘comment_ID) ) . ‘”>’ . mb_strimwidth(strip_tags($comment->comment_content),0,46,”,’utf-8′) . ‘’) . ‘
}
}
显示效果如下:
文章版权声明:除非注明,否则均为主机测评原创文章,转载或复制请以超链接形式并注明出处。
还没有评论,来说两句吧...