WordPress widget latest comments display comment content

WordPress widget latest comments display comment content

The default sidebar of wordpress has a latest comments widget, which does not display the comment content by default. The following modification can display the comment author and comment content.
Modify the file: wp-includes/default-widgets.php
turn up:

 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>' . /* 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>'; } }

to:

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) ) . '”>' . mb_strimwidth(strip_tags($comment->comment_content),0,46,”,'utf-8′) . '</a>') . '</li>';
}
}

The display effect is as follows:

<<:  Ajenti: Excellent Web Management Panel for Linux

>>:  Free VPS: vps.me successful application and shared IP usage tutorial

Recommend

iniz:$7/year/1CPU/128M/10G/250G/1 IP/OpenVZ

The latest offers from iniz include OpenVZ-based ...

JustHost 50% off coupon code

Features: unlimited space, unlimited databases, u...

This site provides DIYPAGE template imitation service

The DIYPAGE program is pretty good and I have bee...

TLD List: Complete domain name discount information

TLD List contains preferential information of 1,5...

DNSZi: Free DNS management in Korea with domain forwarding support

DNSZi is a free DNS service site under PHPSCHOOL,...

Free .top domain name for one year

http://iisp.com/domain/top_domain_promotion.php J...

GlowHost: $55/month/Xeon 5520/16GB memory/2TB hard drive/33TB bandwidth/USA

GlowHost is a long-established hosting company es...

DMIT: $7/month/512MB memory/10GB SSD space/350GB traffic/DDOS/KVM/Hong Kong PCCW

DMIT, an American hosting company (probably a Chi...

Cloudflexy/dedicenter 512MB RAM Hong Kong KVM VPS Review

Details: Cloudflexy: $19/year/512MB memory/10GB s...