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

GreenCloudVPS 2GB RAM 500MBPS Bandwidth Hong Kong Direct KVM VPS Review

Details : GreenCloudVPS: $7/month/2GB RAM/30GB SS...

SecuredSpeed: $3.5/month/1GB memory/35GB space/1TB traffic/OpenVZ/Los Angeles

SecuredSpeed, an American hosting provider, offic...

Netim: .eu domain name discount, 10 years for only 12 euros, only in Europe

Netim.com, owned by FranceDNS, mainly provides do...

HostDare: $44.99/year/756MB memory/150GB space/1TB traffic/KVM/Los Angeles CN2

HostDare, which should be opened by Indians, has ...

OVZH 2GB RAM 100Mbps Port Los Angeles CN2 GIA KVM VPS Review

Details : OVZH: 45 yuan/month/512MB memory/15GB S...

WootHosting: $22/month/8GB memory/320GB space/5TB traffic/5 IP/KVM/Los Angeles

WootHosting, an American hosting provider, was es...

DexHost E5-2603v2 8GB RAM Dedicated Server Los Angeles Simple Review

Details: DexHost: $49/month/i3-2120/8GB RAM/480GB...

Tospeed 512MB RAM 100GB Space Novosibirsk KVM VPS Review

Details: Tospeed: 24 yuan/month/512MB memory/150G...

iranvps Iran VPS Simple Review

Provided by group friends, thanks! Just for every...

Kuai Che Dao: $61/month/1GB memory/10GB space/unlimited traffic/1Gbps/KVM/HKT

Kuai Che Dao, which should be a Chinese merchant,...