Here is just a small code snippet I found for showing the amount of comments a comment author made.
Here’s a function you can use to get and echo the number of comments a comment author made. It’s pretty easy just put it in the functions.php file in your theme.
[php]
function commentCountAuthor(){
$oneText = ‘One comment’;
$moreText = ‘% comments’;
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;
}
[/php]
Then just call the function inside the comments loop and shazam! Magic!
[php]commentCountAuthor();[/php]











Man, Programming was something that always went above my head. Its good to see great people like you who are helping others by giving us the code to get things working.
I feel I should be able to put it in my functions.php file.
Thanks bro
No problem Paul I’m glad I could help you out:)
@Jamie, yeah programming is not an easy nut to crack.
Thanks to people like Jamie who keep helping us out by sharing such awesome stuff!!
Thanks Bobbie and You’re welcome I glad I could help!
Hey Paul,
I agree with you mate…. I’ve been looking for this on google and just reached here.
I believe whether you put the above code above our existing code or below our existing code in functions.php file, It would still work the same, right Jamie??
@Michael, That’s correct Michael just make sure you don’t put it in the middle of a another function or block of code.
@Jamie, Yeah, it messes up big time if we paste it in middle of the functions php code.
It happened to me once with my site. It just stopped working, thank goodness I had created a backup LOL
Hey Jamie,
I really like ur site’s design !!!
r u using thesis theme? by the way, can u pls tell me which plugin are u using for “spread the word” below your posts? It’s really cool looking;)
Thanks Britney
No I’m not using the Thesis Theme but I do like it. “spread the word” isn’t actually a plugin it’s part of my theme.
@Jamie,
Hey, how did you implement spread the word in your theme?
I really liked the idea, would also like to implement something similar on my blog. Please let me know. Thanks
Hi,
Jamie can you please tell me where the comment loop is and in which file?
I am a bit new to php and stuff and so just trying get my hands dirty…..
Thanks so much!
Good work!!
I don’t understand how people have such great skills in programmming? I always used to get a C in my college programming course. lol
’
anyways, its good that u have shared it here. my blog’s commenters would become a lot more happy with this feature
lol
ya Craig, I agree with you
the people who comment on my blog will definitely find this interesting and useful since it will show their number of comments
but dont u think it might discourage commenting if a lot of people just have one or two comments?
@Lila, Its like looking at the half filled glass or half empty one…
I believe It might also encourage one or two comment posters to comment more often……..
dude your blog looks all black and white
Please do not mind but I find it very simple, a web designer should have a blog thats very exciting to view…
Just my 2 cents
I appreciate your comments! @steven
Its good that u explained how to do this
How about writing a post in which you tell us – What are the benefits of showing number of comments of each comment author??
@Gracie, Being a blogger is an exciting job!!
Al lot of the time you get people suggesting new blog posts to write, so you never run out of material… I have subscribed to your feed. nice site design by the way
how do I call function inside comment loop?
Where do I call it? Please tell me, I wanna implement this cool idea for my blog too
@Chriss, I am also a newbie Jamie, pls tell me how do I call the function inside the comments loop.
Thnks in advance
your site design is so sleek and catchy
Which theme are u using? Is it a premium one?
@Nitya, Hey, even I was wondering the same,This seems to be a rocking theme!!
and its load time is also very less
Whats the theme, I would like to give it a shot as well dude.
Hey, even I was wondering the same,This seems to be a rocking theme!!
and its load time is also very less
Whats the theme, I would like to give it a shot as well dude.
Do I need to use a ftp software to make changes in the file or can I do it directly through cpanel?
@Jack, Mate, u can use either of the two methods
filezilla is a nice program if u wanna do it thru ftp.
hope that helps
I use Coda by Panic personally.
Jamie, I am using thesis theme.
I do not have functions.php in it. Instead, I can see a file called custom_functions.php
Where can I put the above code in custom_functions.php file?
I would recommend the bottom. Just make sure not to intersect any other blocks of code.
I believe we can also add some cool wordings if we make changes here:
$oneText = ‘One comment’;
$moreText = ‘% comments’;
for example, changing it to $oneText = ‘starter, 1 comment’;
am I right?
Pretty cool post! However, I find that I am already learning more just from the conversations I am having with other attendees.