Title: Comment counter display
Last modified: May 14, 2020

---

# Comment counter display

 *  Resolved [anthony750](https://wordpress.org/support/users/anthony750/)
 * (@anthony750)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/comment-counter-display/)
 * Good morning, sir,
 * I would like to put the number of comments next to the nickname of the author
   of the comment. Before I had the code but after reinstalling the theme I lost
   the code and it doesn’t work anymore.
 *     ```
       add_filter ('wpdiscuz_comment_author', 'my_commentCount', 10, 2);
       function my_commentCount ($ author_name, $ comment) {
           global $ wpdb;
           $ no_comment = "Aucun commentaire";
           $ one_comment = "Un commentaire";
           $ more_comments = "% commentaires";
            $ count = $ wpdb-> get_var ('SELECT COUNT (comment_ID) FROM'. $ wpdb-> comments. 'WHERE comment_author_email = "'. addlashes ($ comment-> comment_author_email). '"');
           $ comment_text = my_comment_number_text ($ no_comment, $ one_comment, $ more_comments, $ count);
               retourner $ nom_auteur. ' | <span class = "wpdiscuz-comment-count"> '. $ comment_text.' </span> ';
       }
       fonction my_comment_number_text ($ zero = false, $ one = false, $ more = false, $ number = 0) {
           if ($ number> 1) {$ output = str_replace ('%', number_format_i18n ($ number), $ more); } elseif ($ number == 0) {$ output = $ zero; } else {$ output = $ one; } return $ output;
       }
       ```
   
 * [capture](https://www.zupimages.net/up/20/20/hmvs.png)
 * Awaiting your return,
 * Yours sincerely,

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Support [gVectors Support](https://wordpress.org/support/users/gvectorssupportmember/)
 * (@gvectorssupportmember)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/comment-counter-display/#post-12834438)
 * Hi [@anthony750](https://wordpress.org/support/users/anthony750/),
 * The code works fine, just delete the **space**_ after each **$**_ symbol:
    -  This reply was modified 6 years, 1 month ago by [gVectors Support](https://wordpress.org/support/users/gvectorssupportmember/).
    -  This reply was modified 6 years, 1 month ago by [gVectors Support](https://wordpress.org/support/users/gvectorssupportmember/).
 *  Thread Starter [anthony750](https://wordpress.org/support/users/anthony750/)
 * (@anthony750)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/comment-counter-display/#post-12834732)
 * He’s telling me there’s a syntax error, did you find it?
 * [Capture](https://www.zupimages.net/up/20/20/vo4f.png)
 * Yours sincerely,
 *  Plugin Support [gVectors Support](https://wordpress.org/support/users/gvectorssupportmember/)
 * (@gvectorssupportmember)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/comment-counter-display/#post-12838971)
 * Hi [@anthony750](https://wordpress.org/support/users/anthony750/),
 * In the code provided above, there is a wrong part:
 * `retourner $ nom_auteur. ' | <span class = "wpdiscuz-comment-count"> '. $ comment_text.'
   </span> ';`
 * So please replace the code with following one and check again. It should work
   fine:
 *     ```
       add_filter('wpdiscuz_comment_author', 'my_commentCount', 10, 2);
       function my_commentCount($author_name, $comment) {
           global $wpdb;
           $no_comment = "No comments";
           $one_comment = "One comment";
           $more_comments = "% comments";
            $count = $wpdb->get_var('SELECT COUNT(comment_ID) FROM ' . $wpdb->comments. ' WHERE comment_author_email = "' . addslashes($comment->comment_author_email) . '"');
           $comment_text = my_comment_number_text($no_comment, $one_comment, $more_comments, $count);
               return $author_name .' | <span class="wpdiscuz-comment-count">'.$comment_text.'</span>';
       }
       function my_comment_number_text( $zero = false, $one = false, $more = false, $number = 0 ) {
           if ( $number > 1 ) { $output = str_replace( '%', number_format_i18n( $number ), $more); } elseif ( $number == 0 ) { $output = $zero; } else { $output = $one; } return $output;
       }
       ```
   
    -  This reply was modified 6 years, 1 month ago by [gVectors Support](https://wordpress.org/support/users/gvectorssupportmember/).

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Comment counter display’ is closed to new replies.

 * ![](https://ps.w.org/wpdiscuz/assets/icon-256x256.png?rev=1076265)
 * [Comments - wpDiscuz](https://wordpress.org/plugins/wpdiscuz/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wpdiscuz/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wpdiscuz/)
 * [Active Topics](https://wordpress.org/support/plugin/wpdiscuz/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wpdiscuz/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wpdiscuz/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [gVectors Support](https://wordpress.org/support/users/gvectorssupportmember/)
 * Last activity: [6 years, 1 month ago](https://wordpress.org/support/topic/comment-counter-display/#post-12838971)
 * Status: resolved