[Plugin: GD Star Rating] Comments reordering
-
Hi there,
firstly, awesome plugin. By far the best ratings plugin for wordpress, and packed with loads of features.
My wordpress setup is a bit of an odd one, essentially the top level of comments are nominations which users vote on and I’m trying to get them displayed in order of votes as opposed to the traditional wordpress time order. I’ve noticed in forums before that adding this feature has not been possible due to the way that wordpress gets the comments list from the database. I tried hacking this myself and I now see what you mean.
Then I found this: https://www.theunusableweb.com/tips/coding/php-coding/wordpress/re-order-wordpress-comments/
What is described in there is a way to reorder the comments in wordpress based on the currently unused ‘comment karma’ field which is in the database, and I’ve tested this by manually updating the database entry for the comment karma and it works fine. I’m now looking for a way to change the plugin script to allow me to save the overall vote rating (thumb votes) in the karma field which would then allow the comments to be reordered but I’m stuggling a bit with where to put the sql query for this. I was originally just going to write a script that retrieves the up and down votes from the database and then worked out the final vote based on this but doing so would mean the site would be constantly querying the database for every comment and that would just drag.I’m hoping to be able to drop something like this in:
msql_query("INSERT INTO $wpdb->comments (comment_karma) VALUES $vote WHERE comment_id = $id");
where the ‘votes’ variable is equal to the total of votes up minus votes down. This script should run when a vote is cast, but i’m not sure which function I should be dropping this into. i’m currently looking at the ‘add_vote_comment_thumb’ function in the dp.php file, as that is where the votes are saved to the GD star table of the databse. However, every time I drop that statement into the function and test, I just get a spinning pinwheel when the vote is cast and nothing updates in th karma column of the database.
Any ideas?
thanks,
Gusbo
- The topic ‘[Plugin: GD Star Rating] Comments reordering’ is closed to new replies.