Anonymous
Unregistered
Posted 4 years ago #
Not real familiar with WP yet, so alert me of any problems.
Download
wp_comment_leaders
Tag
<?php get_comment_leaders(); ?>
Arguments Definition:
- A number that limits the amount of records that are to be shown. (default's '5')
- A string that excludes certain names from appearing in the list. Separate multiple names with a comma.
- A number: pads the visitor's total comment count with zeros.
- A string to display before the record.
- A string to display after the record. (default is a line break '
')
Example
<?php get_comment_leaders( 10, "admin_name, spammer_name", 3, '
- ', '
'); ?>
OrbitJuice
Member
Posted 4 years ago #
Sweet script. Good work.
I tweaked it a little to the output format I wanted.
You can see it here: http://www.orbitjuice.com
OrbitJuice
Member
Posted 4 years ago #
Also... I edited the code for multiple and single comments.
i.e.:
Eric left 15 comments
Will left 8 comments
John left 2 comments
Mary left 1 comment
Anonymous
Unregistered
Posted 4 years ago #
Anonymous
Unregistered
Posted 4 years ago #
Yea I liked what you did so I changed it to look similar to yours... also made it so that it recognizes single and multiple, comments.also. Thanks
- A number that limits the amount of records that are to be shown. (default's '5')
- A string that excludes certain names from appearing in the list. Separate multiple names with a comma.
- A string to display before the record.
- A string to display between the record. (default "-")
- A string to display after the record. (default is a line break '
')
Example
<?php get_comment_leaders( 10, "admin_name, spammer_name", '
', 'posted', '
'); ?>
OrbitJuice
Member
Posted 4 years ago #
Here is mine. It's a little different. It changes on the output.
if ($author_comment_count != 1) {
echo "$before$comment_author_link - $author_comment_count comments$after";
} else {
echo "$before$comment_author_link - $author_comment_count comment$after"; }
Thanks for this...another thing to play with. ;)
I love this hack. I would like to make som modifications to it, but I'm unsure how. I'd like my output to look like this:
Jess - 184 total
last commented: (date of last comment)
on entry: (entry title last commented on w/link to entry)
Is there a way to do this?
The portion of the function that figures the last comment by an author doesn't work. I was going to try to fix the query, but it's not an easy one.
Hamoudy
Member
Posted 4 years ago #
Yeah I was having the same problem too. With the "Last" section.
MtDew, do you write all the hacks around here? ;-) Or just know everything? 'Cuz you are all over the board helping everyone. What a guy! =)
Thanks for all your help!
I just try to help out as much as I can. :-)
Anonymous
Unregistered
Posted 4 years ago #
Daisyhead yes you can i'll post how to do it in a sec when I figure out whats going on..... MtDewVirus, What exactly isn't working correctly? I don't see the problem that you are talking about.
The query doesn't exactly pull the ID and comment_ID for the last comment by a visitor. At least not from my testing of it. The GROUP BY messes this up. I ran into a similar problem with a hack I wrote and was able to fix it by callin for MAX(comment_ID), but then how do you get the correct ID? You can't pull the MAX(ID) because the latest post commented on by a visitor may not be their latest comment. See what I mean?
I was running the query through phpMyAdmin, trying to get the correct results but so far have been unable to.
You guys are great! I can live without the last date commented. I don't mean to be such a pest. Maybe I just need to tweak my output so it will say:
Jess - 184 total
last on entry: (entry title last commented on w/link to entry)
Is there a way to change that?
Hamoudy
Member
Posted 4 years ago #
Hey Daisyhead
Does the "Last" at the end of your comments leader actually works? and bring up the latest comment by that user?
Anonymous
Unregistered
Posted 4 years ago #
No not at the moment, I'm about to post an updated fixed version later on today.
Kudos to doniboy (and everyone else who had a hand in it)! The hack works splendidly. It was easy to set up and get running. See it On my site. Woo-hoo!
TG
TG,
The portion of the hack that display a link to a commentors last comment is not working correctly yet. I tried to come up with the correct SQL to fix this, but have been unsuccessful yet. doniboy is still working on it also. :-/
Hrm.... I thought it was, but I see now that it doesn't ;) that's OK... if you need my help, just ask (I am a developer by trade and do a lot of SQL).....
TG
Hamoudy
Member
Posted 4 years ago #
~TG
If you can figure this out why it's not giving the last comment. That would be Great. :)
thanks in advance
But....the max comment_post_ID may not be the post that was last commented on. ;) What if a commentor went back and commented on a post from a week ago. That will have the max comment_ID, but pulling the max comment_post_ID will post to the latest post they have commented on. Man, that sounds confusing!
hmmmmm.... I see your point.... OK, I sit corrected.... I'll take a further look at it when I get home (and don't have thinkgs like work cluttering my brain).....
TG
I bet the answer is so simple, that it's rediculous....
Anonymous
Unregistered
Posted 4 years ago #
Yes I concidered using MAX and have cam across the same problems. I'm going to have to take that part of the code out and only show the commentor's name and number of comments into I figure out the best way to do this.. It's giving me a hard time also.
Anonymous
Unregistered
Posted 4 years ago #
Also another problem is how would we go about joining the comment table with the post table so that I can get the title of the last post that the commentor commented on. We'll have the same problem with it pulling the earliest title field instead of the latest one. MAX won't work on this because its a string and it'll sort it in an alphabetical order.
Any suggestions TechGnome?
Yeah, I do have an idea.... unfortunatly it will need to wait until I get home, where I can run MyPHPAdmin properly to test the theory out. I think two selects Joined together somehow will be the answer.
Alex - I didn't think that MySQL 4 supported Inner Selects, but that was something 5.0 was going to support.... hrmm.... I don't know.... ;)
I will look at it tonight and see what I can do....
TG
Wuuuup!
Latest version of comment leaders hack can be found right here! It appears to work for me now, getting the proper post AND comment. I would appreciate it if I could get some "independant" confirmation on this.
Unfortunatly, I could not get it to work with one SQL call, and broke it up into two calls.
TG
Hamoudy
Member
Posted 4 years ago #
~TG
Good Job man... It works just fine. Way to Go. Check it out Here
It's under the Recent Tab ;)
Thanks again!
Two cheers for the Gnome.