Neueste Kommentare im WordPress-Widget zeigen den Kommentarinhalt an

Neueste Kommentare im WordPress-Widget zeigen den Kommentarinhalt an

Die Standard-Seitenleiste von WordPress verfügt über ein Widget für die neuesten Kommentare, das standardmäßig nicht den Kommentarinhalt anzeigt. Die folgende Änderung kann den Autor und den Inhalt des Kommentars anzeigen.
Ändern Sie die Datei: wp-includes/default-widgets.php
auftauchen:

 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>'; } }

Zu:

wenn ( $Kommentare ) {
foreach ( (Array) $Kommentare als $Kommentar) {
$output .= '<li class="recentcomments">' . /* Übersetzer: Kommentar-Widget:
1: Autor des Kommentars, 2: Link zum Beitrag */ 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>';
}
}

Der Anzeigeeffekt ist wie folgt:

<<:  Ajenti: Ausgezeichnetes Web-Management-Panel für Linux

>>:  Kostenloses VPS: Tutorial zur erfolgreichen Anmeldung bei vps.me und zur Nutzung gemeinsam genutzter IPs

Artikel empfehlen

Auswirkungen: 3 $/Jahr/256 MB/5 GB SSD/250 GB Bandbreite/OpenVZ/Seattle/Dallas

Impact, 50 % Rabatt, ab nur 3 $. Gutscheincode: E...