Anzahl der Kommentare eines Benutzers
Mithilfe dieses Code-Schnipsels kannst du die Anzahl der Kommentare eines Kommentators anzeigen lassen.
Füge den ersten Teil der functions.php deines WordPress Themes bei. Der zweite Block gehört in die comments.php an die Stelle wo du die totale Anzahl der Kommentare eines Benutzers angezeigt haben möchtest.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | function commentCountAuthor(){ $oneText = 'Ein Kommentar'; $moreText = '% Kommentare'; global $wpdb; $result = $wpdb->get_var(' SELECT COUNT(comment_ID) FROM '.$wpdb->comments.' WHERE comment_author_email = "'.get_comment_author_email().'"' ); if($result == 1): echo str_replace('%', $result, $oneText); elseif($result > 1): echo str_replace('%', $result, $moreText); endif; } |
1 2 3 | <?php commentCountAuthor(); ?> |